Common/FileSearch: Refactor DoFileSearch

This commit is contained in:
Sintendo committed 2026-01-24 16:50:10 +01:00
1 parent 3221e982d3
commit f2e1c71803
19 files changed
+87 -48

No files matched your search

+4 -4
View File
@@ -28,12 +28,12 @@ namespace UICommon
{
static constexpr u32 CACHE_REVISION = 26; // Last changed in PR 10084
std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan,
std::vector<std::string> FindAllGamePaths(std::span<const std::string_view> directories_to_scan,
bool recursive_scan)
{
static const std::vector<std::string> search_extensions = {
".gcm", ".tgc", ".bin", ".iso", ".ciso", ".gcz", ".wbfs",
".wia", ".rvz", ".nfs", ".wad", ".dol", ".elf", ".json"};
constexpr auto search_extensions =
std::to_array<std::string_view>({".gcm", ".tgc", ".bin", ".iso", ".ciso", ".gcz", ".wbfs",
".wia", ".rvz", ".nfs", ".wad", ".dol", ".elf", ".json"});
// TODO: We could process paths iteratively as they are found
return Common::DoFileSearch(directories_to_scan, search_extensions, recursive_scan);
+1 -1
View File
@@ -19,7 +19,7 @@ namespace UICommon
{
class GameFile;
std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan,
std::vector<std::string> FindAllGamePaths(std::span<const std::string_view> directories_to_scan,
bool recursive_scan);
class GameFileCache
@@ -32,7 +32,7 @@ bool Init()
{
packs.clear();
const std::vector<std::string> pack_list =
Common::DoFileSearch({File::GetUserPath(D_RESOURCEPACK_IDX)}, {".zip"});
Common::DoFileSearch(File::GetUserPath(D_RESOURCEPACK_IDX), ".zip");
Common::IniFile file = GetPackConfig();
@@ -305,7 +305,7 @@ bool ResourcePack::Uninstall(const std::string& path)
while (dir.length() > (path + TEXTURE_PATH).length())
{
auto is_empty = Common::DoFileSearch({dir}).empty();
const auto is_empty = Common::DoFileSearch(dir).empty();
if (is_empty)
File::DeleteDir(dir);