Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/os_chdir.c')
-rw-r--r--src/host/os_chdir.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/host/os_chdir.c b/src/host/os_chdir.c
new file mode 100644
index 0000000..3acce68
--- /dev/null
+++ b/src/host/os_chdir.c
@@ -0,0 +1,32 @@
+/**
+ * \file os_chdir.c
+ * \brief Change the current working directory.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+
+
+int os_chdir(lua_State* L)
+{
+ int z;
+ const char* path = luaL_checkstring(L, 1);
+
+#if PLATFORM_WINDOWS
+ z = SetCurrentDirectory(path);
+#else
+ z = !chdir(path);
+#endif
+
+ if (!z)
+ {
+ lua_pushnil(L);
+ lua_pushfstring(L, "unable to switch to directory '%s'", path);
+ return 2;
+ }
+ else
+ {
+ lua_pushboolean(L, 1);
+ return 1;
+ }
+}