Changeset

2443:b335ae55af77

util.pposix: Add mkdir(path)
author Matthew Wild <mwild1@gmail.com>
date Sun, 10 Jan 2010 23:12:22 +0000
parents 2442:94c676b585c0
children 2444:267d6482bac6
files util-src/pposix.c
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
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 },