MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / DirList

Method DirList

src/lua/LuaVFS.cpp:330–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328//============================================================================//
329
330int LuaVFS::DirList(lua_State* L) {
331 const char* path = luaL_checkstring(L, 1);
332 std::string modes = luaL_optstring(L, 2, GetReadFilter(path, L));
333 modes = BzVFS::allowModes(modes, L2ES(L)->vfsModes->readAllowed);
334
335 const bool recursive = lua_isboolean(L, 3) && lua_tobool(L, 3);
336
337 std::vector<std::string> files;
338 std::vector<std::string> dirs;
339 if (!bzVFS.dirList(path, modes, recursive, dirs, files)) {
340 lua_pushnil(L);
341 return 1;
342 }
343
344 lua_createtable(L, files.size(), 0);
345 for (size_t i = 0; i < files.size(); i++) {
346 const std::string& fpath = files[i];
347 lua_pushinteger(L, i + 1);
348 lua_pushstdstring(L, fpath);
349 lua_rawset(L, -3);
350 }
351
352 lua_createtable(L, dirs.size(), 0);
353 for (size_t i = 0; i < dirs.size(); i++) {
354 const std::string& dpath = dirs[i];
355 lua_pushinteger(L, i + 1);
356 lua_pushstdstring(L, dpath);
357 lua_rawset(L, -3);
358 }
359
360 return 2;
361}
362
363
364//============================================================================//

Callers

nothing calls this directly

Calls 10

GetReadFilterFunction · 0.85
L2ESFunction · 0.85
lua_toboolFunction · 0.85
lua_pushstdstringFunction · 0.85
lua_pushnilFunction · 0.50
lua_createtableFunction · 0.50
lua_pushintegerFunction · 0.50
lua_rawsetFunction · 0.50
dirListMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected