summaryrefslogtreecommitdiff
path: root/src/granger/src/premake/os_mkdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/granger/src/premake/os_mkdir.c')
-rw-r--r--src/granger/src/premake/os_mkdir.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/granger/src/premake/os_mkdir.c b/src/granger/src/premake/os_mkdir.c
new file mode 100644
index 0000000..a7a69db
--- /dev/null
+++ b/src/granger/src/premake/os_mkdir.c
@@ -0,0 +1,33 @@
+/**
+ * \file os_mkdir.c
+ * \brief Create a subdirectory.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include <sys/stat.h>
+#include "premake.h"
+
+
+int os_mkdir(lua_State* L)
+{
+ int z;
+ const char* path = luaL_checkstring(L, 1);
+
+#if PLATFORM_WINDOWS
+ z = CreateDirectory(path, NULL);
+#else
+ z = (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0);
+#endif
+
+ if (!z)
+ {
+ lua_pushnil(L);
+ lua_pushfstring(L, "unable to create directory '%s'", path);
+ return 2;
+ }
+ else
+ {
+ lua_pushboolean(L, 1);
+ return 1;
+ }
+}