(Windows) Fixed an issue where Unicode characters in folder names would sometimes crash the application

This commit is contained in:
Leon Styhre 2023-10-17 23:58:38 +02:00
parent 436d21ec92
commit 78a4223b8e

View file

@ -71,21 +71,25 @@ namespace Utils
return contentList; return contentList;
if (recursive) { if (recursive) {
for (auto& entry : std::filesystem::recursive_directory_iterator(genericPath)) {
#if defined(_WIN64) #if defined(_WIN64)
for (auto& entry : std::filesystem::recursive_directory_iterator(
Utils::String::stringToWideString(genericPath))) {
contentList.emplace_back( contentList.emplace_back(
Utils::String::wideStringToString(entry.path().generic_wstring())); Utils::String::wideStringToString(entry.path().generic_wstring()));
#else #else
for (auto& entry : std::filesystem::recursive_directory_iterator(genericPath)) {
contentList.emplace_back(entry.path().generic_string()); contentList.emplace_back(entry.path().generic_string());
#endif #endif
} }
} }
else { else {
for (auto& entry : std::filesystem::directory_iterator(genericPath)) {
#if defined(_WIN64) #if defined(_WIN64)
for (auto& entry : std::filesystem::directory_iterator(
Utils::String::stringToWideString(genericPath))) {
contentList.emplace_back( contentList.emplace_back(
Utils::String::wideStringToString(entry.path().generic_wstring())); Utils::String::wideStringToString(entry.path().generic_wstring()));
#else #else
for (auto& entry : std::filesystem::directory_iterator(genericPath)) {
contentList.emplace_back(entry.path().generic_string()); contentList.emplace_back(entry.path().generic_string());
#endif #endif
} }