MCPcopy Create free account
hub / github.com/F-Stack/f-stack / findfile

Function findfile

app/redis-6.2.6/deps/lua/src/loadlib.c:351–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349
350
351static const char *findfile (lua_State *L, const char *name,
352 const char *pname) {
353 const char *path;
354 name = luaL_gsub(L, name, ".", LUA_DIRSEP);
355 lua_getfield(L, LUA_ENVIRONINDEX, pname);
356 path = lua_tostring(L, -1);
357 if (path == NULL)
358 luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
359 lua_pushliteral(L, ""); /* error accumulator */
360 while ((path = pushnexttemplate(L, path)) != NULL) {
361 const char *filename;
362 filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
363 lua_remove(L, -2); /* remove path template */
364 if (readable(filename)) /* does file exist and is readable? */
365 return filename; /* return that file name */
366 lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
367 lua_remove(L, -2); /* remove file name */
368 lua_concat(L, 2); /* add entry to possible error message */
369 }
370 return NULL; /* not found */
371}
372
373
374static void loaderror (lua_State *L, const char *filename) {

Callers 3

loader_LuaFunction · 0.85
loader_CFunction · 0.85
loader_CrootFunction · 0.85

Calls 8

pushnexttemplateFunction · 0.85
readableFunction · 0.85
luaL_gsubFunction · 0.70
lua_getfieldFunction · 0.70
luaL_errorFunction · 0.70
lua_removeFunction · 0.70
lua_pushfstringFunction · 0.70
lua_concatFunction · 0.70

Tested by

no test coverage detected