MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / cliLuaListDir

Function cliLuaListDir

Source/Basic/Application.cpp:281–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281int cliLuaListDir(lua_State* L) {
282 auto path = cliGetString(L, 1);
283 std::error_code err;
284 if (!fs::is_directory(path, err)) {
285 lua_newtable(L);
286 return 1;
287 }
288 lua_newtable(L);
289 int i = 1;
290 for (const auto& entry : fs::directory_iterator(path, err)) {
291 if (err) break;
292 lua_newtable(L);
293 auto name = entry.path().filename().string();
294 auto fullPath = entry.path().string();
295 lua_pushlstring(L, name.c_str(), name.size());
296 lua_setfield(L, -2, "name");
297 lua_pushlstring(L, fullPath.c_str(), fullPath.size());
298 lua_setfield(L, -2, "path");
299 lua_pushboolean(L, entry.is_directory());
300 lua_setfield(L, -2, "isDir");
301 lua_pushboolean(L, entry.is_regular_file());
302 lua_setfield(L, -2, "isFile");
303 lua_rawseti(L, -2, i++);
304 }
305 return 1;
306}
307
308int cliLuaMTime(lua_State* L) {
309 std::error_code err;

Callers

nothing calls this directly

Calls 13

cliGetStringFunction · 0.85
is_directoryFunction · 0.85
is_directoryMethod · 0.80
is_regular_fileMethod · 0.80
lua_pushlstringFunction · 0.50
lua_setfieldFunction · 0.50
lua_pushbooleanFunction · 0.50
lua_rawsetiFunction · 0.50
stringMethod · 0.45
filenameMethod · 0.45
pathMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected