Started fix for infinite recursion in directory trees.

This commit is contained in:
Aloshi 2013-04-13 16:33:18 -05:00
parent 1e2cc1eb0a
commit 4a05288e71
2 changed files with 24 additions and 0 deletions

View file

@ -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();

View file

@ -38,6 +38,7 @@ private:
std::string mLaunchCommand;
void populateFolder(FolderData* folder);
bool containsFolder(FolderData* folder, const std::string& path);
FolderData* mRootFolder;
};