AP_Scripting: added stat() binding for filesystem

This commit is contained in:
Andrew Tridgell committed 2023-12-11 18:00:38 +11:00
1 parent 2822f507c1
commit 90c12d4db3
4 files changed
+20 -26

No files matched your search

-19
View File
@@ -721,25 +721,6 @@ int lua_dirlist(lua_State *L) {
return 1; /* table is already on top */
}
/*
return true if path is a directory
*/
int lua_isdirectory(lua_State *L) {
binding_argcheck(L, 1);
const char *path = luaL_checkstring(L, 1);
struct stat st;
if (AP::FS().stat(path, &st) != 0) {
lua_pushnil(L); /* return nil and ... */
lua_pushstring(L, strerror(errno)); /* error message */
return 2;
}
bool ret = (st.st_mode & S_IFMT) == S_IFDIR;
lua_pushboolean(L, ret);
return 1;
}
/*
remove a file
*/