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

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/os_getcwd.c')
-rw-r--r--src/host/os_getcwd.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/host/os_getcwd.c b/src/host/os_getcwd.c
index 06c91a2..de8bfbd 100644
--- a/src/host/os_getcwd.c
+++ b/src/host/os_getcwd.c
@@ -9,26 +9,28 @@
int os_getcwd(lua_State* L)
{
char buffer[0x4000];
- char* ch;
+ if (do_getcwd(buffer, 0x4000)) {
+ lua_pushstring(L, buffer);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+int do_getcwd(char* buffer, size_t size)
+{
int result;
#if PLATFORM_WINDOWS
- result = (GetCurrentDirectory(0x4000, buffer) != 0);
+ result = (GetCurrentDirectory(size, buffer) != 0);
+ if (result) {
+ do_translate(buffer, '/');
+ }
#else
- result = (getcwd(buffer, 0x4000) != 0);
+ result = (getcwd(buffer, size) != 0);
#endif
- if (!result)
- return 0;
-
- /* convert to platform-neutral directory separators */
- for (ch = buffer; *ch != '\0'; ++ch)
- {
- if (*ch == '\\') *ch = '/';
- }
-
- lua_pushstring(L, buffer);
- return 1;
+ return result;
}
-
-