From 55895bbbe0676f00a08fce5d6df869549e1817a2 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 7 Jun 2024 21:24:39 +0200 Subject: [PATCH] Check for looping symlinks when building PHP projects --- codelitephp/PHPParser/FilesCollector.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/codelitephp/PHPParser/FilesCollector.cpp b/codelitephp/PHPParser/FilesCollector.cpp index 8d86982da2..64e61dcdbf 100644 --- a/codelitephp/PHPParser/FilesCollector.cpp +++ b/codelitephp/PHPParser/FilesCollector.cpp @@ -31,6 +31,7 @@ void FilesCollector::Collect(const wxString& rootFolder) m_filesAndFolders.clear(); return; } + std::unordered_set visitedFolders; std::queue Q; Q.push(rootFolder); @@ -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);