Fixed a regression where filesystem case-sensitivity was not considered when looking for media files for the screensaver

This commit is contained in:
Leon Styhre 2024-09-20 10:58:26 +02:00
parent 31c8e76e47
commit a463b6fa2d

View file

@ -425,14 +425,47 @@ void Screensaver::generateImageList()
"/titlescreens"};
const std::string mediaDirCovers {FileData::getMediaDirectory() +
(*it)->getRootFolder()->getSystemName() + "/covers"};
const Utils::FileSystem::StringList dirContentMiximages {
Utils::FileSystem::getDirContent(mediaDirMiximages, true)};
const Utils::FileSystem::StringList dirContentScreenshots {
Utils::FileSystem::getDirContent(mediaDirScreenshots, true)};
const Utils::FileSystem::StringList dirContentTitlescreens {
Utils::FileSystem::getDirContent(mediaDirTitlescreens, true)};
const Utils::FileSystem::StringList dirContentCovers {
Utils::FileSystem::getDirContent(mediaDirCovers, true)};
Utils::FileSystem::StringList dirContentMiximages;
Utils::FileSystem::StringList dirContentScreenshots;
Utils::FileSystem::StringList dirContentTitlescreens;
Utils::FileSystem::StringList dirContentCovers;
#if defined(_WIN64) || defined(__APPLE__) || defined(__ANDROID__)
// Although macOS may have filesystem case-sensitivity enabled it's rare and the impact
// would not be severe in this case anyway.
const bool caseSensitiveFilesystem {false};
#else
const bool caseSensitiveFilesystem {true};
#endif
for (auto& entry : Utils::FileSystem::getDirContent(mediaDirMiximages, true)) {
if (caseSensitiveFilesystem)
dirContentMiximages.emplace_back(entry);
else
dirContentMiximages.emplace_back(Utils::String::toLower(entry));
}
for (auto& entry : Utils::FileSystem::getDirContent(mediaDirScreenshots, true)) {
if (caseSensitiveFilesystem)
dirContentScreenshots.emplace_back(entry);
else
dirContentScreenshots.emplace_back(Utils::String::toLower(entry));
}
for (auto& entry : Utils::FileSystem::getDirContent(mediaDirTitlescreens, true)) {
if (caseSensitiveFilesystem)
dirContentTitlescreens.emplace_back(entry);
else
dirContentTitlescreens.emplace_back(Utils::String::toLower(entry));
}
for (auto& entry : Utils::FileSystem::getDirContent(mediaDirCovers, true)) {
if (caseSensitiveFilesystem)
dirContentCovers.emplace_back(entry);
else
dirContentCovers.emplace_back(Utils::String::toLower(entry));
}
std::string subFolders;
@ -450,26 +483,38 @@ void Screensaver::generateImageList()
const std::string gamePath {subFolders + "/" + (*it2)->getDisplayName()};
for (auto& extension : FileData::sImageExtensions) {
if (std::find(dirContentMiximages.cbegin(), dirContentMiximages.cend(),
mediaDirMiximages + gamePath + extension) !=
if (std::find(
dirContentMiximages.cbegin(), dirContentMiximages.cend(),
(caseSensitiveFilesystem ?
mediaDirMiximages + gamePath + extension :
Utils::String::toLower(mediaDirMiximages + gamePath + extension))) !=
dirContentMiximages.cend()) {
mImageFiles.push_back((*it2));
break;
}
if (std::find(dirContentScreenshots.cbegin(), dirContentScreenshots.cend(),
mediaDirScreenshots + gamePath + extension) !=
if (std::find(
dirContentScreenshots.cbegin(), dirContentScreenshots.cend(),
(caseSensitiveFilesystem ?
mediaDirScreenshots + gamePath + extension :
Utils::String::toLower(mediaDirScreenshots + gamePath + extension))) !=
dirContentScreenshots.cend()) {
mImageFiles.push_back((*it2));
break;
}
if (std::find(dirContentTitlescreens.cbegin(), dirContentTitlescreens.cend(),
mediaDirTitlescreens + gamePath + extension) !=
(caseSensitiveFilesystem ?
mediaDirTitlescreens + gamePath + extension :
Utils::String::toLower(mediaDirTitlescreens + gamePath +
extension))) !=
dirContentTitlescreens.cend()) {
mImageFiles.push_back((*it2));
break;
}
if (std::find(dirContentCovers.cbegin(), dirContentCovers.cend(),
mediaDirCovers + gamePath + extension) != dirContentCovers.cend()) {
(caseSensitiveFilesystem ?
mediaDirCovers + gamePath + extension :
Utils::String::toLower(mediaDirCovers + gamePath +
extension))) != dirContentCovers.cend()) {
mImageFiles.push_back((*it2));
break;
}
@ -497,8 +542,21 @@ void Screensaver::generateVideoList()
// very expensive on such problematic platforms.
const std::string mediaDir {FileData::getMediaDirectory() +
(*it)->getRootFolder()->getSystemName() + "/videos"};
const Utils::FileSystem::StringList dirContent {
Utils::FileSystem::getDirContent(mediaDir, true)};
Utils::FileSystem::StringList dirContent;
#if defined(_WIN64) || defined(__APPLE__) || defined(__ANDROID__)
// Although macOS may have filesystem case-sensitivity enabled it's rare and the impact
// would not be severe in this case anyway.
const bool caseSensitiveFilesystem {false};
#else
const bool caseSensitiveFilesystem {true};
#endif
for (auto& entry : Utils::FileSystem::getDirContent(mediaDir, true)) {
if (caseSensitiveFilesystem)
dirContent.emplace_back(entry);
else
dirContent.emplace_back(Utils::String::toLower(entry));
}
std::string subFolders;
@ -517,7 +575,10 @@ void Screensaver::generateVideoList()
for (auto& extension : FileData::sVideoExtensions) {
if (std::find(dirContent.cbegin(), dirContent.cend(),
mediaDir + gamePath + extension) != dirContent.cend()) {
(caseSensitiveFilesystem ?
mediaDir + gamePath + extension :
Utils::String::toLower(mediaDir + gamePath + extension))) !=
dirContent.cend()) {
mVideoFiles.push_back((*it2));
break;
}