GameList: Slight optimization to scanning

This commit is contained in:
Connor McLaughlin
2021-02-18 18:07:09 +10:00
parent 3ab7e140ee
commit 1b544ae350
4 changed files with 37 additions and 17 deletions

View File

@ -52,6 +52,16 @@ const char* GameList::GetGameListCompatibilityRatingString(GameListCompatibility
"";
}
bool GameList::IsScannableFilename(const std::string& path)
{
// we don't scan bin files because they'll duplicate
std::string::size_type pos = path.rfind('.');
if (pos != std::string::npos && StringUtil::Strcasecmp(path.c_str() + pos, ".bin") == 0)
return false;
return System::IsLoadableFilename(path.c_str());
}
bool GameList::GetExeListEntry(const char* path, GameListEntry* entry)
{
FILESYSTEM_STAT_DATA ffd;
@ -499,24 +509,8 @@ void GameList::ScanDirectory(const char* path, bool recursive, ProgressCallback*
for (const FILESYSTEM_FIND_DATA& ffd : files)
{
progress->IncrementProgressValue();
// if this is a .bin, check if we have a .cue. if there is one, skip it
const char* extension = std::strrchr(ffd.FileName.c_str(), '.');
if (extension && StringUtil::Strcasecmp(extension, ".bin") == 0)
{
#if 0
std::string temp(ffd.FileName, extension - ffd.FileName);
temp += ".cue";
if (std::any_of(files.begin(), files.end(),
[&temp](const FILESYSTEM_FIND_DATA& it) { return StringUtil::Strcasecmp(it.FileName, temp.c_str()) == 0; }))
{
Log_DebugPrintf("Skipping due to '%s' existing", temp.c_str());
continue;
}
#else
if (!IsScannableFilename(ffd.FileName))
continue;
#endif
}
std::string entry_path(ffd.FileName);
if (std::any_of(m_entries.begin(), m_entries.end(),

View File

@ -94,6 +94,8 @@ public:
/// Returns a string representation of a compatibility level.
static const char* GetGameListCompatibilityRatingString(GameListCompatibilityRating rating);
static bool IsScannableFilename(const std::string& path);
const EntryList& GetEntries() const { return m_entries; }
const u32 GetEntryCount() const { return static_cast<u32>(m_entries.size()); }
const std::vector<DirectoryEntry>& GetSearchDirectories() const { return m_search_directories; }