AP_Scripting: added isdirectory()
This commit is contained in:
parent
9065baa329
commit
3446ff78d7
@ -3062,6 +3062,11 @@ function scripting:restart_all() end
|
||||
---@return table -- table of filenames
|
||||
function dirlist(directoryname) end
|
||||
|
||||
-- return true if path is a directory
|
||||
---@param path string
|
||||
---@return result
|
||||
function isdirectory(path) end
|
||||
|
||||
--desc
|
||||
---@param filename string
|
||||
function remove(filename) end
|
||||
|
@ -812,6 +812,7 @@ userdata uint32_t manual tofloat uint32_t_tofloat 0
|
||||
|
||||
global manual dirlist lua_dirlist 1
|
||||
global manual remove lua_removefile 1
|
||||
global manual isdirectory lua_isdirectory 1
|
||||
global manual print lua_print 1
|
||||
|
||||
singleton mavlink depends HAL_GCS_ENABLED
|
||||
|
@ -720,6 +720,25 @@ 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
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@ int lua_get_CAN_device(lua_State *L);
|
||||
int lua_get_CAN_device2(lua_State *L);
|
||||
int lua_dirlist(lua_State *L);
|
||||
int lua_removefile(lua_State *L);
|
||||
int lua_isdirectory(lua_State *L);
|
||||
int SRV_Channels_get_safety_state(lua_State *L);
|
||||
int lua_get_PWMSource(lua_State *L);
|
||||
int lua_get_SocketAPM(lua_State *L);
|
||||
|
Loading…
Reference in New Issue
Block a user