mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Add core.mkdir
This commit is contained in:
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "cpp_api/s_async.h"
|
||||
#include "serialization.h"
|
||||
#include "json/json.h"
|
||||
#include "cpp_api/s_security.h"
|
||||
#include "debug.h"
|
||||
#include "porting.h"
|
||||
#include "log.h"
|
||||
@@ -327,6 +328,17 @@ int ModApiUtil::l_decompress(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// mkdir(path)
|
||||
int ModApiUtil::l_mkdir(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
const char *path = luaL_checkstring(L, 1);
|
||||
CHECK_SECURE_PATH_OPTIONAL(L, path);
|
||||
lua_pushboolean(L, fs::CreateAllDirs(path));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ModApiUtil::Initialize(lua_State *L, int top)
|
||||
{
|
||||
API_FCT(debug);
|
||||
@@ -352,6 +364,8 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
||||
|
||||
API_FCT(compress);
|
||||
API_FCT(decompress);
|
||||
|
||||
API_FCT(mkdir);
|
||||
}
|
||||
|
||||
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
||||
@@ -374,5 +388,7 @@ void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
||||
|
||||
ASYNC_API_FCT(compress);
|
||||
ASYNC_API_FCT(decompress);
|
||||
|
||||
ASYNC_API_FCT(mkdir);
|
||||
}
|
||||
|
||||
|
@@ -78,7 +78,7 @@ private:
|
||||
// is_yes(arg)
|
||||
static int l_is_yes(lua_State *L);
|
||||
|
||||
// get_scriptdir()
|
||||
// get_builtin_path()
|
||||
static int l_get_builtin_path(lua_State *L);
|
||||
|
||||
// compress(data, method, ...)
|
||||
@@ -87,6 +87,9 @@ private:
|
||||
// decompress(data, method, ...)
|
||||
static int l_decompress(lua_State *L);
|
||||
|
||||
// mkdir(path)
|
||||
static int l_mkdir(lua_State *L);
|
||||
|
||||
public:
|
||||
static void Initialize(lua_State *L, int top);
|
||||
|
||||
|
Reference in New Issue
Block a user