MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / findfile

Function findfile

Source/Misc/lua/src/lua.c:13119–13139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13117
13118
13119static const char *findfile (lua_State *L, const char *name,
13120const char *pname) {
13121const char *path;
13122name = luaL_gsub(L, name, ".", LUA_DIRSEP);
13123lua_getfield(L, LUA_ENVIRONINDEX, pname);
13124path = lua_tostring(L, -1);
13125if (path == NULL)
13126luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
13127lua_pushliteral(L, ""); /* error accumulator */
13128while ((path = pushnexttemplate(L, path)) != NULL) {
13129const char *filename;
13130filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
13131lua_remove(L, -2); /* remove path template */
13132if (readable(filename)) /* does file exist and is readable? */
13133return filename; /* return that file name */
13134lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
13135lua_remove(L, -2); /* remove file name */
13136lua_concat(L, 2); /* add entry to possible error message */
13137}
13138return NULL; /* not found */
13139}
13140
13141
13142static void loaderror (lua_State *L, const char *filename) {

Callers 3

loader_LuaFunction · 0.85
loader_CFunction · 0.85
loader_CrootFunction · 0.85

Calls 8

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

Tested by

no test coverage detected