mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 19:39:56 -05:00
Add the ability for LuaLibrary%s to reference script files that will be executed (closing #328)
Create documentation for Lua scripts Add Lua script to check if a file exists
This commit is contained in:
@@ -226,6 +226,30 @@ int setPathToken(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* walkDirectory(string, bool, bool):
|
||||
* Walks a directory and returns the contents of the directory as absolute paths. The
|
||||
* first argument is the path of the directory that should be walked, the second argument
|
||||
* determines if the walk is recursive and will continue in contained directories. The
|
||||
* default value for this parameter is "false". The third argument determines whether the
|
||||
* table that is returned is sorted. The default value for this parameter is "false".
|
||||
*/
|
||||
int fileExists(lua_State* L) {
|
||||
const int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
}
|
||||
|
||||
const std::string file = luaL_checkstring(L, -1);
|
||||
const bool e = FileSys.fileExists(absPath(file));
|
||||
lua_pushboolean(
|
||||
L,
|
||||
e ? 1 : 0
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* walkDirectory(string, bool, bool):
|
||||
|
||||
Reference in New Issue
Block a user