mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-12-11 06:55:40 +00:00
Fixed an issue where placing a directory with no access permissions inside a system folder crashed the application on startup
This commit is contained in:
parent
ce580a269f
commit
d380db8a1f
|
@ -67,29 +67,42 @@ namespace Utils
|
||||||
if (!isDirectory(genericPath))
|
if (!isDirectory(genericPath))
|
||||||
return contentList;
|
return contentList;
|
||||||
|
|
||||||
if (recursive) {
|
try {
|
||||||
|
if (recursive) {
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
for (auto& entry : std::filesystem::recursive_directory_iterator(
|
for (auto& entry : std::filesystem::recursive_directory_iterator(
|
||||||
Utils::String::stringToWideString(genericPath))) {
|
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)) {
|
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 {
|
||||||
|
#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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
catch (...) {
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
for (auto& entry : std::filesystem::directory_iterator(
|
LOG(LogError) << "FileSystemUtil::getDirContent(): Couldn't read directory " << "\""
|
||||||
Utils::String::stringToWideString(genericPath))) {
|
<< Utils::String::replace(path, "/", "\\")
|
||||||
contentList.emplace_back(
|
<< "\", permission problems?";
|
||||||
Utils::String::wideStringToString(entry.path().generic_wstring()));
|
|
||||||
#else
|
#else
|
||||||
for (auto& entry : std::filesystem::directory_iterator(genericPath)) {
|
LOG(LogError) << "FileSystemUtil::getDirContent(): Couldn't read directory " << "\""
|
||||||
contentList.emplace_back(entry.path().generic_string());
|
<< path << "\", permission problems?";
|
||||||
#endif
|
#endif
|
||||||
}
|
return contentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
contentList.sort();
|
contentList.sort();
|
||||||
|
|
Loading…
Reference in a new issue