1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add core.mkdir

This commit is contained in:
ShadowNinja 2014-09-09 15:17:01 -04:00
parent 3a8c788880
commit 05ab9973f9
3 changed files with 49 additions and 33 deletions

View file

@ -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);
}