Common/FileSearch: Refactor DoFileSearch

This commit is contained in:
Sintendo
2026-01-24 16:50:10 +01:00
parent 3221e982d3
commit f2e1c71803
19 changed files with 87 additions and 48 deletions
@@ -534,7 +534,7 @@ void MappingWindow::PopulateProfileSelection()
m_profiles_combo->clear();
const std::string profiles_path = m_config->GetUserProfileDirectoryPath();
for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"}))
for (const auto& filename : Common::DoFileSearch(profiles_path, ".ini"))
{
std::string basename;
SplitPath(filename, nullptr, &basename, nullptr);
@@ -544,8 +544,7 @@ void MappingWindow::PopulateProfileSelection()
m_profiles_combo->insertSeparator(m_profiles_combo->count());
for (const auto& filename :
Common::DoFileSearch({m_config->GetSysProfileDirectoryPath()}, {".ini"}))
for (const auto& filename : Common::DoFileSearch(m_config->GetSysProfileDirectoryPath(), ".ini"))
{
std::string basename;
SplitPath(filename, nullptr, &basename, nullptr);
@@ -109,7 +109,7 @@ void RiivolutionBootWidget::LoadMatchingXMLs()
{
const std::string& riivolution_dir = File::GetUserPath(D_RIIVOLUTION_IDX);
const auto config = LoadConfigXML(riivolution_dir);
for (const std::string& path : Common::DoFileSearch({riivolution_dir + "riivolution"}, {".xml"}))
for (const std::string& path : Common::DoFileSearch(riivolution_dir + "riivolution", ".xml"))
{
auto parsed = DiscIO::Riivolution::ParseFile(path);
if (!parsed || !parsed->IsValidForGame(m_game_id, m_revision, m_disc_number))
@@ -132,8 +132,8 @@ void InterfacePane::CreateUI()
combobox_layout->addRow(tr("&Language:"), m_combobox_language);
// List available themes
auto theme_paths =
Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR});
auto theme_paths = Common::DoFileSearch(
{{File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR}});
std::vector<std::string> theme_names;
theme_names.reserve(theme_paths.size());
std::ranges::transform(theme_paths, std::back_inserter(theme_names), PathToFileName);
@@ -147,7 +147,7 @@ void InterfacePane::CreateUI()
m_label_userstyle = new QLabel(tr("Style:"));
combobox_layout->addRow(m_label_userstyle, m_combobox_userstyle);
auto userstyle_search_results = Common::DoFileSearch({File::GetUserPath(D_STYLES_IDX)});
auto userstyle_search_results = Common::DoFileSearch(File::GetUserPath(D_STYLES_IDX));
m_combobox_userstyle->addItem(tr("(System)"), static_cast<int>(Settings::StyleType::System));