#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <errno.h>
#ifdef _MSC_VER
#include <direct.h>
+#endif
+#ifdef G_OS_WIN32
int mkstemp (char *tmp_template);
#endif
}
} 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;
}
-