summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/PathUtils.h7
-rw-r--r--utils/fs/fs.c2
-rw-r--r--utils/fs/fs.h6
3 files changed, 11 insertions, 4 deletions
diff --git a/rts/PathUtils.h b/rts/PathUtils.h
index b1746f8769..8a42e34b54 100644
--- a/rts/PathUtils.h
+++ b/rts/PathUtils.h
@@ -12,10 +12,13 @@
// Use wchar_t for pathnames on Windows (#5697)
#if defined(mingw32_HOST_OS)
+#include "fs_rts.h"
+
#define pathcmp wcscmp
#define pathlen wcslen
-#define pathopen __rts_fwopen
-#define pathstat _wstat
+// N.B. Use the Win32-based file routines from utils/fs.
+#define pathopen FS(fwopen)
+#define pathstat FS(_wstat)
#define struct_stat struct _stat
#define open wopen
#define WSTR(s) L##s
diff --git a/utils/fs/fs.c b/utils/fs/fs.c
index ebed2ca0fc..a5377af7e2 100644
--- a/utils/fs/fs.c
+++ b/utils/fs/fs.c
@@ -21,8 +21,6 @@
#include <io.h>
#include <fcntl.h>
#include <wchar.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <share.h>
#include <errno.h>
diff --git a/utils/fs/fs.h b/utils/fs/fs.h
index 9e4b8e2052..6c5f56ccdd 100644
--- a/utils/fs/fs.h
+++ b/utils/fs/fs.h
@@ -25,6 +25,12 @@
#if defined(_WIN32)
#include <wchar.h>
+// N.B. <sys/stat.h> defines some macro rewrites to, e.g., turn _wstat into
+// _wstat64i32. We must include it here to ensure tat this rewrite applies to
+// both the definition and use sites.
+#include <sys/types.h>
+#include <sys/stat.h>
+
wchar_t* FS(create_device_name) (const wchar_t*);
int FS(translate_mode) (const wchar_t*);
int FS(swopen) (const wchar_t* filename, int oflag,