MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / searchpath

Function searchpath

src/Chain/libraries/glua/loadlib.cpp:401–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399
400
401static const char *searchpath(lua_State *L, const char *name,
402 const char *path,
403 const char *sep,
404 const char *dirsep) {
405 //if (glua::util::starts_with(name, ADDRESS_CONTRACT_PREFIX))
406 // return nullptr;
407 luaL_Buffer msg; /* to build error message */
408 luaL_buffinit(L, &msg);
409 if (*sep != '\0') /* non-empty separator? */
410 name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */
411 while ((path = pushnexttemplate(L, path)) != nullptr) { // 这步好像改变了lua_real_execute_contract_api函数中的api_name的内容
412 const char *filename = luaL_gsub(L, lua_tostring(L, -1),
413 LUA_PATH_MARK, name);
414 lua_remove(L, -2); /* remove path template */
415 if (readable(filename)) /* does file exist and is readable? */
416 return filename; /* return that file name */
417 lua_pushfstring(L, "\n\tno file '%s'", filename);
418 lua_remove(L, -2); // remove file name
419 luaL_addvalue(&msg); /* concatenate error msg. entry */
420 }
421 luaL_pushresult(&msg); /* create error message */
422 return nullptr; /* not found */
423}
424
425
426static int ll_searchpath(lua_State *L) {

Callers 2

ll_searchpathFunction · 0.85
findfileFunction · 0.85

Calls 7

luaL_buffinitFunction · 0.85
luaL_gsubFunction · 0.85
pushnexttemplateFunction · 0.85
readableFunction · 0.85
lua_pushfstringFunction · 0.85
luaL_addvalueFunction · 0.85
luaL_pushresultFunction · 0.85

Tested by

no test coverage detected