aboutsummaryrefslogtreecommitdiffstats
path: root/util-src
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-01-10 23:12:22 +0000
committerMatthew Wild <mwild1@gmail.com>2010-01-10 23:12:22 +0000
commit238beb4df640a6d2f1373f594842a56880c6ce78 (patch)
tree39b43458481689bdd2f0ce6ee8421653ca124497 /util-src
parent82ca2f393bef2895ef09df70beac455bc28e4c45 (diff)
downloadprosody-238beb4df640a6d2f1373f594842a56880c6ce78.tar.gz
prosody-238beb4df640a6d2f1373f594842a56880c6ce78.zip
util.pposix: Add mkdir(path)
Diffstat (limited to 'util-src')
-rw-r--r--util-src/pposix.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 49521a16..9627dab7 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -371,6 +371,21 @@ int lc_umask(lua_State* L)
return 1;
}
+int lc_mkdir(lua_State* L)
+{
+ int ret = mkdir(luaL_checkstring(L, 1), S_IRUSR | S_IWUSR | S_IXUSR
+ | S_IRGRP | S_IWGRP | S_IXGRP
+ | S_IROTH | S_IXOTH); /* mode 775 */
+
+ lua_pushboolean(L, ret==0);
+ if(ret)
+ {
+ lua_pushstring(L, strerror(errno));
+ return 2;
+ }
+ return 1;
+}
+
/* Like POSIX's setrlimit()/getrlimit() API functions.
*
* Syntax:
@@ -505,6 +520,8 @@ int luaopen_util_pposix(lua_State *L)
{ "umask", lc_umask },
+ { "mkdir", lc_mkdir },
+
{ "setrlimit", lc_setrlimit },
{ "getrlimit", lc_getrlimit },