diff options
Diffstat (limited to 'util-src/pposix.c')
-rw-r--r-- | util-src/pposix.c | 17 |
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 }, |