Skip to content

Commit

Permalink
Check for looping symlinks when building PHP projects
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Jun 7, 2024
1 parent 02fa54e commit 55895bb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions codelitephp/PHPParser/FilesCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void FilesCollector::Collect(const wxString& rootFolder)
m_filesAndFolders.clear();
return;
}
std::unordered_set<wxString> visitedFolders;
std::queue<wxString> Q;
Q.push(rootFolder);

Expand All @@ -50,11 +51,14 @@ void FilesCollector::Collect(const wxString& rootFolder)
fullpath << dir.GetNameWithSep() << filename;
bool isDirectory = wxFileName::DirExists(fullpath);
if(isDirectory && (m_excludeFolders.count(filename) == 0)) {
// A directory
Q.push(fullpath);
fullpath << wxFileName::GetPathSeparator() << FOLDER_MARKER;
V.push_back(fullpath);

wxString canonicalPath = wxFileName(fullpath).ResolveLink().GetFullPath();
if (visitedFolders.find(canonicalPath) == visitedFolders.end()) {
visitedFolders.insert(canonicalPath);
// A directory
Q.push(fullpath);
fullpath << wxFileName::GetPathSeparator() << FOLDER_MARKER;
V.push_back(fullpath);
}
} else if(!isDirectory && IsFileOK(filename)) {
// A file
V.push_back(fullpath);
Expand Down

0 comments on commit 55895bb

Please sign in to comment.