diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-09-04 21:44:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 21:44:44 +0200 |
commit | c4865921ec8f2a4f5d3440b2b2abe5dbe289a4b9 (patch) | |
tree | 733c4c4ec88d2b72812beaadefa8f009290b7f52 | |
parent | 5c4dffe7c23fcf03f2cee7aa5d703fed4f7147f8 (diff) | |
parent | 82cd97b675ac1af251bbde9ebb2f8d0a53191f59 (diff) |
Merge pull request #41770 from bruvzg/fix_mono_win_build
Fix Mono path utils char types.
-rw-r--r-- | modules/mono/utils/path_utils.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index d91dcb5981..5d1abd0c09 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -54,12 +54,16 @@ String cwd() { #ifdef WINDOWS_ENABLED const DWORD expected_size = ::GetCurrentDirectoryW(0, nullptr); - String buffer; + Char16String buffer; buffer.resize((int)expected_size); - if (::GetCurrentDirectoryW(expected_size, buffer.ptrw()) == 0) + if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) return "."; - return buffer.simplify_path(); + String result; + if (result.parse_utf16(buffer.ptr())) { + return "."; + } + return result.simplify_path(); #else char buffer[PATH_MAX]; if (::getcwd(buffer, sizeof(buffer)) == nullptr) { @@ -100,12 +104,18 @@ String realpath(const String &p_path) { return p_path; } - String buffer; + Char16String buffer; buffer.resize((int)expected_size); - ::GetFinalPathNameByHandleW(hFile, buffer.ptrw(), expected_size, FILE_NAME_NORMALIZED); + ::GetFinalPathNameByHandleW(hFile, (wchar_t *)buffer.ptrw(), expected_size, FILE_NAME_NORMALIZED); ::CloseHandle(hFile); - return buffer.simplify_path(); + + String result; + if (result.parse_utf16(buffer.ptr())) { + return p_path; + } + + return result.simplify_path(); #elif UNIX_ENABLED char *resolved_path = ::realpath(p_path.utf8().get_data(), nullptr); |