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:
comex
2014-11-15 15:46:40 -05:00
parent 6ff3fcee59
commit a225426510
17 changed files with 156 additions and 348 deletions

View File

@ -25,9 +25,9 @@ void AbstractGameList::RemoveGames(QList<GameFile*> items)
DGameTracker::DGameTracker(QWidget* parent_widget)
: QStackedWidget(parent_widget),
m_watcher(this)
m_watcher(new QFileSystemWatcher(this))
{
connect(&m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(ScanForGames()));
connect(m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(ScanForGames()));
m_tree_widget = new DGameTree(this);
addWidget(m_tree_widget);
@ -78,38 +78,20 @@ void DGameTracker::ScanForGames()
{
setDisabled(true);
CFileSearch::XStringVector dirs(SConfig::GetInstance().m_ISOFolder);
delete m_watcher;
m_watcher = new QFileSystemWatcher(this);
if (SConfig::GetInstance().m_RecursiveISOFolder)
{
for (u32 i = 0; i < dirs.size(); i++)
{
File::FSTEntry FST_Temp;
File::ScanDirectoryTree(dirs[i], FST_Temp);
for (auto& entry : FST_Temp.children)
{
if (entry.isDirectory)
{
bool duplicate = false;
for (auto& dir : dirs)
{
if (dir == entry.physicalName)
{
duplicate = true;
break;
}
}
if (!duplicate)
dirs.push_back(entry.physicalName);
}
}
}
for (std::string dir : FindSubdirectories(SConfig::GetInstance().m_ISOFolder, /*recursive*/ true))
m_watcher->addPath(QString::fromStdString(dir));
}
else
{
for (std::string dir : SConfig::GetInstance().m_ISOFolder)
m_watcher->addPath(QString::fromStdString(dir));
}
for (std::string& dir : dirs)
m_watcher.addPath(QString::fromStdString(dir));
CFileSearch::XStringVector exts;
std::vector<std::string> exts;
if (SConfig::GetInstance().m_ListGC)
{
exts.push_back("*.gcm");
@ -124,8 +106,7 @@ void DGameTracker::ScanForGames()
if (SConfig::GetInstance().m_ListWad)
exts.push_back("*.wad");
CFileSearch FileSearch(exts, dirs);
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
auto rFilenames = DoFileSearch(exts, SConfig::GetInstance().m_ISOFolder, SConfig::GetInstance().m_RecursiveISOFolder);
QList<GameFile*> newItems;
QStringList allItems;

View File

@ -60,7 +60,7 @@ public slots:
private:
QMap<QString, GameFile*> m_games;
QFileSystemWatcher m_watcher;
QFileSystemWatcher* m_watcher;
GameListStyle m_current_style;
DGameGrid* m_grid_widget = nullptr;