Fix g_dir_open et al for windows.
[mono.git] / eglib / src / gfile-posix.c
index ab96109067360d07384104753ce6b9463b4d9b2a..17005661d25b81bf640710dc7af9c7e4ec7c8911 100644 (file)
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 
 #ifdef _MSC_VER
+#include <direct.h>
 int mkstemp (char *tmp_template);
 #endif
 
@@ -161,6 +162,10 @@ g_get_current_dir (void)
                }
        } while (fail);
 
-       return r;
+       /* On amd64 sometimes the bottom 32-bits of r == the bottom 32-bits of buffer
+        * but the top 32-bits of r have overflown to 0xffffffff (seriously wtf getcwd
+        * so we return the buffer here since it has a pointer to the valid string
+        */
+       return buffer;
 }