From 78a4223b8e4cb5fe14a31d11d81c9f212832fac3 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 17 Oct 2023 23:58:38 +0200 Subject: [PATCH] (Windows) Fixed an issue where Unicode characters in folder names would sometimes crash the application --- es-core/src/utils/FileSystemUtil.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index c36226e30..c8f56de7c 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -71,21 +71,25 @@ namespace Utils return contentList; if (recursive) { - for (auto& entry : std::filesystem::recursive_directory_iterator(genericPath)) { #if defined(_WIN64) + for (auto& entry : std::filesystem::recursive_directory_iterator( + Utils::String::stringToWideString(genericPath))) { contentList.emplace_back( Utils::String::wideStringToString(entry.path().generic_wstring())); #else + for (auto& entry : std::filesystem::recursive_directory_iterator(genericPath)) { contentList.emplace_back(entry.path().generic_string()); #endif } } else { - for (auto& entry : std::filesystem::directory_iterator(genericPath)) { #if defined(_WIN64) + for (auto& entry : std::filesystem::directory_iterator( + Utils::String::stringToWideString(genericPath))) { contentList.emplace_back( Utils::String::wideStringToString(entry.path().generic_wstring())); #else + for (auto& entry : std::filesystem::directory_iterator(genericPath)) { contentList.emplace_back(entry.path().generic_string()); #endif }