Software /
code /
prosody
Diff
util-src/pposix.c @ 2443:b335ae55af77
util.pposix: Add mkdir(path)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 10 Jan 2010 23:12:22 +0000 |
parent | 2441:d72078946a16 |
child | 2455:0b3184f3c9e4 |
line wrap: on
line diff
--- a/util-src/pposix.c Sun Jan 10 23:11:28 2010 +0000 +++ b/util-src/pposix.c Sun Jan 10 23:12:22 2010 +0000 @@ -371,6 +371,21 @@ 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 @@ { "umask", lc_umask }, + { "mkdir", lc_mkdir }, + { "setrlimit", lc_setrlimit }, { "getrlimit", lc_getrlimit },