MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / searchpath

Function searchpath

libraries/AP_Scripting/lua/src/loadlib.c:440–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438
439
440static const char *searchpath (lua_State *L, const char *name,
441 const char *path,
442 const char *sep,
443 const char *dirsep) {
444 luaL_Buffer msg; /* to build error message */
445 luaL_buffinit(L, &msg);
446 if (*sep != '\0') /* non-empty separator? */
447 name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */
448 while ((path = pushnexttemplate(L, path)) != NULL) {
449 const char *filename = luaL_gsub(L, lua_tostring(L, -1),
450 LUA_PATH_MARK, name);
451 lua_remove(L, -2); /* remove path template */
452 if (readable(filename)) /* does file exist and is readable? */
453 return filename; /* return that file name */
454 lua_pushfstring(L, "\n\tno file '%s'", filename);
455 lua_remove(L, -2); /* remove file name */
456 luaL_addvalue(&msg); /* concatenate error msg. entry */
457 }
458 luaL_pushresult(&msg); /* create error message */
459 return NULL; /* not found */
460}
461
462
463static 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