Fix file listing on submounts.
This commit is contained in:
parent
a0c9085cca
commit
4b4ce47ed1
|
@ -44,8 +44,13 @@ static int file_list( lua_State* L )
|
||||||
lua_newtable( L );
|
lua_newtable( L );
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while ((e = readdir(dir))) {
|
while ((e = readdir(dir))) {
|
||||||
|
char *fname;
|
||||||
|
asprintf(&fname, "%s/%s", dirname, e->d_name);
|
||||||
|
if (!fname)
|
||||||
|
return luaL_error(L, "no memory");
|
||||||
struct stat st = { 0, };
|
struct stat st = { 0, };
|
||||||
stat(e->d_name, &st);
|
stat(fname, &st);
|
||||||
|
free(fname);
|
||||||
lua_pushinteger(L, st.st_size);
|
lua_pushinteger(L, st.st_size);
|
||||||
lua_setfield(L, -2, e->d_name);
|
lua_setfield(L, -2, e->d_name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue