From 5a9f8c30629bb46faabf24c162b9db7cb8ab3084 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 24 Nov 2024 10:58:15 +0000 Subject: [PATCH] f_open: use non-Unicode pathnames on legacy Windows. --- windows/utils/filename.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/windows/utils/filename.c b/windows/utils/filename.c index 68c4c1cf..8f4c53af 100644 --- a/windows/utils/filename.c +++ b/windows/utils/filename.c @@ -86,6 +86,15 @@ char filename_char_sanitise(char c) FILE *f_open(const Filename *fn, const char *mode, bool isprivate) { +#ifdef LEGACY_WINDOWS + /* Fallback for legacy pre-NT windows, where as far as I can see + * _wfopen just doesn't work at all */ + init_winver(); + if (osPlatformId == VER_PLATFORM_WIN32_WINDOWS || + osPlatformId == VER_PLATFORM_WIN32s) + return fopen(fn->cpath, mode); +#endif + wchar_t *wmode = dup_mb_to_wc(DEFAULT_CODEPAGE, mode); FILE *fp = _wfopen(fn->wpath, wmode); sfree(wmode);