| 3349 | }; |
| 3350 | |
| 3351 | static int filesystem_listdir(lua_State *L) |
| 3352 | { |
| 3353 | luaL_checktype(L,1,LUA_TSTRING); |
| 3354 | string dir=lua_tostring(L,1); |
| 3355 | vector<std::filesystem::path> files; |
| 3356 | int err = DFHack::Filesystem::listdir(dir, files); |
| 3357 | if (err) |
| 3358 | { |
| 3359 | lua_pushnil(L); |
| 3360 | lua_pushstring(L, strerror(err)); |
| 3361 | lua_pushinteger(L, err); |
| 3362 | return 3; |
| 3363 | } |
| 3364 | lua_newtable(L); |
| 3365 | for(size_t i=0;i<files.size();i++) |
| 3366 | { |
| 3367 | lua_pushinteger(L,i+1); |
| 3368 | lua_pushstring(L,Filesystem::as_string(files[i]).c_str()); |
| 3369 | lua_settable(L,-3); |
| 3370 | } |
| 3371 | return 1; |
| 3372 | } |
| 3373 | |
| 3374 | static int filesystem_listdir_recursive(lua_State *L) |
| 3375 | { |
nothing calls this directly
no test coverage detected