mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-21 08:55:21 +01:00
Implement core.path_exists() (#16647)
This commit is contained in:
@@ -263,6 +263,21 @@ int ModApiUtil::l_is_yes(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// path_exists(path)
|
||||
int ModApiUtil::l_path_exists(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
std::string path = luaL_checkstring(L, 1); //path
|
||||
|
||||
CHECK_SECURE_PATH(L, path.c_str(), false);
|
||||
|
||||
bool exists = fs::PathExists(path);
|
||||
lua_pushboolean(L, exists);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_builtin_path()
|
||||
int ModApiUtil::l_get_builtin_path(lua_State *L)
|
||||
{
|
||||
@@ -724,6 +739,8 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
||||
|
||||
API_FCT(is_yes);
|
||||
|
||||
API_FCT(path_exists);
|
||||
|
||||
API_FCT(get_builtin_path);
|
||||
API_FCT(get_user_path);
|
||||
|
||||
@@ -809,6 +826,8 @@ void ModApiUtil::InitializeAsync(lua_State *L, int top)
|
||||
|
||||
API_FCT(is_yes);
|
||||
|
||||
API_FCT(path_exists);
|
||||
|
||||
API_FCT(get_builtin_path);
|
||||
API_FCT(get_user_path);
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ private:
|
||||
// is_yes(arg)
|
||||
static int l_is_yes(lua_State *L);
|
||||
|
||||
// path_exists(path)
|
||||
static int l_path_exists(lua_State *L);
|
||||
|
||||
// get_builtin_path()
|
||||
static int l_get_builtin_path(lua_State *L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user