mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Rewrite FileSearch and improve ScanDirectoryTree.
- FileSearch is now just one function, and it converts the original glob into a regex on all platforms rather than relying on native Windows pattern matching on there and a complete hack elsewhere. It now supports recursion out of the box rather than manually expanding into a full list of directories in multiple call sites. - This adds a GCC >= 4.9 dependency due to older versions having outright broken <regex>. MSVC is fine with it. - ScanDirectoryTree returns the parent entry rather than filling parts of it in via reference. The count is now stored in the entry like it was for subdirectories. - .glsl file search is now done with DoFileSearch. - IOCTLV_READ_DIR now uses ScanDirectoryTree directly and sorts the results after replacements for better determinism.
This commit is contained in:
@ -162,12 +162,10 @@ void InterfaceConfigPane::LoadGUIValues()
|
||||
|
||||
void InterfaceConfigPane::LoadThemes()
|
||||
{
|
||||
CFileSearch::XStringVector theme_dirs;
|
||||
theme_dirs.push_back(File::GetUserPath(D_THEMES_IDX));
|
||||
theme_dirs.push_back(File::GetSysDirectory() + THEMES_DIR);
|
||||
|
||||
CFileSearch cfs(CFileSearch::XStringVector(1, "*"), theme_dirs);
|
||||
auto const& sv = cfs.GetFileNames();
|
||||
auto sv = DoFileSearch({"*"}, {
|
||||
File::GetUserPath(D_THEMES_IDX),
|
||||
File::GetSysDirectory() + THEMES_DIR
|
||||
}, /*recursive*/ false);
|
||||
for (const std::string& filename : sv)
|
||||
{
|
||||
std::string name, ext;
|
||||
|
@ -1966,15 +1966,9 @@ void CFrame::GameListChanged(wxCommandEvent& event)
|
||||
SConfig::GetInstance().m_ListDrives = event.IsChecked();
|
||||
break;
|
||||
case IDM_PURGE_CACHE:
|
||||
CFileSearch::XStringVector Directories;
|
||||
Directories.push_back(File::GetUserPath(D_CACHE_IDX));
|
||||
CFileSearch::XStringVector Extensions;
|
||||
Extensions.push_back("*.cache");
|
||||
std::vector<std::string> rFilenames = DoFileSearch({"*.cache"}, {File::GetUserPath(D_CACHE_IDX)});
|
||||
|
||||
CFileSearch FileSearch(Extensions, Directories);
|
||||
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
|
||||
|
||||
for (auto& rFilename : rFilenames)
|
||||
for (const std::string& rFilename : rFilenames)
|
||||
{
|
||||
File::Delete(rFilename);
|
||||
}
|
||||
|
@ -466,35 +466,7 @@ void CGameListCtrl::ScanForISOs()
|
||||
{
|
||||
ClearIsoFiles();
|
||||
|
||||
CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder);
|
||||
|
||||
if (SConfig::GetInstance().m_RecursiveISOFolder)
|
||||
{
|
||||
for (u32 i = 0; i < Directories.size(); i++)
|
||||
{
|
||||
File::FSTEntry FST_Temp;
|
||||
File::ScanDirectoryTree(Directories[i], FST_Temp);
|
||||
for (auto& Entry : FST_Temp.children)
|
||||
{
|
||||
if (Entry.isDirectory)
|
||||
{
|
||||
bool duplicate = false;
|
||||
for (auto& Directory : Directories)
|
||||
{
|
||||
if (Directory == Entry.physicalName)
|
||||
{
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!duplicate)
|
||||
Directories.push_back(Entry.physicalName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CFileSearch::XStringVector Extensions;
|
||||
std::vector<std::string> Extensions;
|
||||
|
||||
if (SConfig::GetInstance().m_ListGC)
|
||||
Extensions.push_back("*.gcm");
|
||||
@ -508,8 +480,7 @@ void CGameListCtrl::ScanForISOs()
|
||||
if (SConfig::GetInstance().m_ListWad)
|
||||
Extensions.push_back("*.wad");
|
||||
|
||||
CFileSearch FileSearch(Extensions, Directories);
|
||||
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
|
||||
auto rFilenames = DoFileSearch(Extensions, SConfig::GetInstance().m_ISOFolder, SConfig::GetInstance().m_RecursiveISOFolder);
|
||||
|
||||
if (rFilenames.size() > 0)
|
||||
{
|
||||
|
@ -172,18 +172,14 @@ void InputConfigDialog::UpdateProfileComboBox()
|
||||
pname += PROFILES_PATH;
|
||||
pname += m_config.profile_name;
|
||||
|
||||
CFileSearch::XStringVector exts;
|
||||
exts.push_back("*.ini");
|
||||
CFileSearch::XStringVector dirs;
|
||||
dirs.push_back(pname);
|
||||
CFileSearch cfs(exts, dirs);
|
||||
const CFileSearch::XStringVector& sv = cfs.GetFileNames();
|
||||
std::vector<std::string> sv = DoFileSearch({"*.ini"}, {pname});
|
||||
|
||||
wxArrayString strs;
|
||||
for (auto si = sv.cbegin(); si != sv.cend(); ++si)
|
||||
for (const std::string& filename : sv)
|
||||
{
|
||||
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
|
||||
strs.push_back(StrToWxStr(str));
|
||||
std::string base;
|
||||
SplitPath(filename, nullptr, &base, nullptr);
|
||||
strs.push_back(StrToWxStr(base));
|
||||
}
|
||||
|
||||
for (GamepadPage* page : m_padpages)
|
||||
|
Reference in New Issue
Block a user