diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-09-09 15:17:01 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2015-05-16 18:32:37 -0400 |
commit | 05ab9973f9029676dfa252617c8cb698ab13eb24 (patch) | |
tree | 38737835d842be0f7df15cd13389800683c935b1 /src | |
parent | 3a8c7888807e4483bbdb3edd81c9893f3e2f427d (diff) | |
download | minetest-05ab9973f9029676dfa252617c8cb698ab13eb24.tar.gz minetest-05ab9973f9029676dfa252617c8cb698ab13eb24.tar.bz2 minetest-05ab9973f9029676dfa252617c8cb698ab13eb24.zip |
Add core.mkdir
Diffstat (limited to 'src')
-rw-r--r-- | src/script/lua_api/l_util.cpp | 16 | ||||
-rw-r--r-- | src/script/lua_api/l_util.h | 5 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp index 151d449d5..e16b6feab 100644 --- a/src/script/lua_api/l_util.cpp +++ b/src/script/lua_api/l_util.cpp @@ -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); } diff --git a/src/script/lua_api/l_util.h b/src/script/lua_api/l_util.h index e82432381..bf7cd71d3 100644 --- a/src/script/lua_api/l_util.h +++ b/src/script/lua_api/l_util.h @@ -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); |