From 2791f1e1275afe0d584523f65eaa4200ea35a6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 4 Oct 2021 20:11:47 +0200 Subject: [PATCH] fix fs_removedir and fs_remove with unicode on windows --- src/base/system.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/base/system.cpp b/src/base/system.cpp index 9f1af68c6..437017b84 100644 --- a/src/base/system.cpp +++ b/src/base/system.cpp @@ -2271,7 +2271,9 @@ int fs_makedir(const char *path) int fs_removedir(const char *path) { #if defined(CONF_FAMILY_WINDOWS) - if(_rmdir(path) == 0) + WCHAR wPath[IO_MAX_PATH_LENGTH]; + MultiByteToWideChar(CP_UTF8, 0, path, IO_MAX_PATH_LENGTH, wPath, IO_MAX_PATH_LENGTH); + if(RemoveDirectoryW(wPath) != 0) return 0; return -1; #else @@ -2357,7 +2359,9 @@ int fs_parent_dir(char *path) int fs_remove(const char *filename) { #if defined(CONF_FAMILY_WINDOWS) - return _unlink(filename) != 0; + WCHAR wFilename[IO_MAX_PATH_LENGTH]; + MultiByteToWideChar(CP_UTF8, 0, filename, IO_MAX_PATH_LENGTH, wFilename, IO_MAX_PATH_LENGTH); + return DeleteFileW(wFilename) == 0; #else return unlink(filename) != 0; #endif