mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Started fix for infinite recursion in directory trees.
This commit is contained in:
parent
1e2cc1eb0a
commit
4a05288e71
|
@ -88,6 +88,20 @@ void SystemData::launchGame(Window* window, GameData* game)
|
|||
window->init();
|
||||
}
|
||||
|
||||
bool SystemData::containsFolder(FolderData* root, const std::string& path)
|
||||
{
|
||||
for(int i = 0; i < root->getFileCount(); i++)
|
||||
{
|
||||
FileData* f = root->getFile(i);
|
||||
if(f->isFolder())
|
||||
{
|
||||
if(f->getPath() == path || containsFolder((FolderData*)f, path))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SystemData::populateFolder(FolderData* folder)
|
||||
{
|
||||
std::string folderPath = folder->getPath();
|
||||
|
@ -97,6 +111,15 @@ void SystemData::populateFolder(FolderData* folder)
|
|||
return;
|
||||
}
|
||||
|
||||
//make sure that this isn't a symlink to a thing we already have
|
||||
if(fs::is_symlink(folderPath))
|
||||
{
|
||||
if(containsFolder(mRootFolder, folderPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(fs::directory_iterator end, dir(folderPath); dir != end; ++dir)
|
||||
{
|
||||
fs::path filePath = (*dir).path();
|
||||
|
|
|
@ -38,6 +38,7 @@ private:
|
|||
std::string mLaunchCommand;
|
||||
|
||||
void populateFolder(FolderData* folder);
|
||||
bool containsFolder(FolderData* folder, const std::string& path);
|
||||
|
||||
FolderData* mRootFolder;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue