Add core.mkdir
parent
3a8c788880
commit
05ab9973f9
|
@ -1674,36 +1674,36 @@ Helper functions
|
||||||
* Useful for storing custom data
|
* Useful for storing custom data
|
||||||
* `minetest.is_singleplayer()`
|
* `minetest.is_singleplayer()`
|
||||||
* `minetest.features`
|
* `minetest.features`
|
||||||
* table containing API feature flags: `{foo=true, bar=true}`
|
* Table containing API feature flags: `{foo=true, bar=true}`
|
||||||
* `minetest.has_feature(arg)`: returns `boolean, missing_features`
|
* `minetest.has_feature(arg)`: returns `boolean, missing_features`
|
||||||
* `arg`: string or table in format `{foo=true, bar=true}`
|
* `arg`: string or table in format `{foo=true, bar=true}`
|
||||||
* `missing_features`: `{foo=true, bar=true}`
|
* `missing_features`: `{foo=true, bar=true}`
|
||||||
* `minetest.get_player_information(playername)`
|
* `minetest.get_player_information(player_name)`: returns a table containing
|
||||||
* table containing information about player peer.
|
information about player. Example return value:
|
||||||
|
{
|
||||||
Example of `minetest.get_player_information` return value:
|
address = "127.0.0.1", -- IP address of client
|
||||||
|
ip_version = 4, -- IPv4 / IPv6
|
||||||
{
|
min_rtt = 0.01, -- minimum round trip time
|
||||||
address = "127.0.0.1", -- IP address of client
|
max_rtt = 0.2, -- maximum round trip time
|
||||||
ip_version = 4, -- IPv4 / IPv6
|
avg_rtt = 0.02, -- average round trip time
|
||||||
min_rtt = 0.01, -- minimum round trip time
|
min_jitter = 0.01, -- minimum packet time jitter
|
||||||
max_rtt = 0.2, -- maximum round trip time
|
max_jitter = 0.5, -- maximum packet time jitter
|
||||||
avg_rtt = 0.02, -- average round trip time
|
avg_jitter = 0.03, -- average packet time jitter
|
||||||
min_jitter = 0.01, -- minimum packet time jitter
|
connection_uptime = 200, -- seconds since client connected
|
||||||
max_jitter = 0.5, -- maximum packet time jitter
|
|
||||||
avg_jitter = 0.03, -- average packet time jitter
|
-- following information is available on debug build only!!!
|
||||||
connection_uptime = 200, -- seconds since client connected
|
-- DO NOT USE IN MODS
|
||||||
|
--ser_vers = 26, -- serialization version used by client
|
||||||
-- following information is available on debug build only!!!
|
--prot_vers = 23, -- protocol version used by client
|
||||||
-- DO NOT USE IN MODS
|
--major = 0, -- major version number
|
||||||
--ser_vers = 26, -- serialization version used by client
|
--minor = 4, -- minor version number
|
||||||
--prot_vers = 23, -- protocol version used by client
|
--patch = 10, -- patch version number
|
||||||
--major = 0, -- major version number
|
--vers_string = "0.4.9-git", -- full version string
|
||||||
--minor = 4, -- minor version number
|
--state = "Active" -- current client state
|
||||||
--patch = 10, -- patch version number
|
}
|
||||||
--vers_string = "0.4.9-git", -- full version string
|
* `minetest.mkdir(path)`: returns success.
|
||||||
--state = "Active" -- current client state
|
* Creates a directory specified by `path`, creating parent directories
|
||||||
}
|
if they don't exist.
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
* `minetest.debug(line)`
|
* `minetest.debug(line)`
|
||||||
|
@ -2282,11 +2282,8 @@ These functions return the leftover itemstack.
|
||||||
the floor or ceiling
|
the floor or ceiling
|
||||||
* The first four options are mutually-exclusive; the last in the list takes
|
* The first four options are mutually-exclusive; the last in the list takes
|
||||||
precedence over the first.
|
precedence over the first.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* `minetest.rotate_node(itemstack, placer, pointed_thing)`
|
* `minetest.rotate_node(itemstack, placer, pointed_thing)`
|
||||||
* calls `rotate_and_place()` with infinitestacks set according to the state of
|
* calls `rotate_and_place()` with infinitestacks set according to the state of
|
||||||
the creative mode setting, and checks for "sneak" to set the `invert_wall`
|
the creative mode setting, and checks for "sneak" to set the `invert_wall`
|
||||||
parameter.
|
parameter.
|
||||||
|
|
||||||
|
@ -2306,7 +2303,7 @@ minetest.global_exists(name)
|
||||||
* Any function in the minetest namespace can be called using the syntax
|
* Any function in the minetest namespace can be called using the syntax
|
||||||
`minetest.env:somefunction(somearguments)`
|
`minetest.env:somefunction(somearguments)`
|
||||||
instead of `minetest.somefunction(somearguments)`
|
instead of `minetest.somefunction(somearguments)`
|
||||||
* Deprecated, but support is not to be dropped soon
|
* Deprecated, but support is not to be dropped soon
|
||||||
|
|
||||||
### Global tables
|
### Global tables
|
||||||
* `minetest.registered_items`
|
* `minetest.registered_items`
|
||||||
|
|
|
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "cpp_api/s_async.h"
|
#include "cpp_api/s_async.h"
|
||||||
#include "serialization.h"
|
#include "serialization.h"
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
|
#include "cpp_api/s_security.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -327,6 +328,17 @@ int ModApiUtil::l_decompress(lua_State *L)
|
||||||
return 1;
|
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)
|
void ModApiUtil::Initialize(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
API_FCT(debug);
|
API_FCT(debug);
|
||||||
|
@ -352,6 +364,8 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
||||||
|
|
||||||
API_FCT(compress);
|
API_FCT(compress);
|
||||||
API_FCT(decompress);
|
API_FCT(decompress);
|
||||||
|
|
||||||
|
API_FCT(mkdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
||||||
|
@ -374,5 +388,7 @@ void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
||||||
|
|
||||||
ASYNC_API_FCT(compress);
|
ASYNC_API_FCT(compress);
|
||||||
ASYNC_API_FCT(decompress);
|
ASYNC_API_FCT(decompress);
|
||||||
|
|
||||||
|
ASYNC_API_FCT(mkdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ private:
|
||||||
// is_yes(arg)
|
// is_yes(arg)
|
||||||
static int l_is_yes(lua_State *L);
|
static int l_is_yes(lua_State *L);
|
||||||
|
|
||||||
// get_scriptdir()
|
// get_builtin_path()
|
||||||
static int l_get_builtin_path(lua_State *L);
|
static int l_get_builtin_path(lua_State *L);
|
||||||
|
|
||||||
// compress(data, method, ...)
|
// compress(data, method, ...)
|
||||||
|
@ -87,6 +87,9 @@ private:
|
||||||
// decompress(data, method, ...)
|
// decompress(data, method, ...)
|
||||||
static int l_decompress(lua_State *L);
|
static int l_decompress(lua_State *L);
|
||||||
|
|
||||||
|
// mkdir(path)
|
||||||
|
static int l_mkdir(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize(lua_State *L, int top);
|
static void Initialize(lua_State *L, int top);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue