From 7ede0feb2c1772b2de4513f2186fb613eb93a771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 11 Apr 2019 18:46:57 +0200 Subject: [PATCH] Better handling for excluded paths --- lib/importproject.cpp | 13 ++++++++----- lib/importproject.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 1c0e9b5b2..4e3c8b5b9 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -36,7 +36,8 @@ void ImportProject::ignorePaths(const std::vector &ipaths) { for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { bool ignore = false; - for (const std::string &i : ipaths) { + for (std::string i : ipaths) { + i = mPath + i; if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) { ignore = true; break; @@ -173,14 +174,16 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings std::ifstream fin(filename); if (!fin.is_open()) return ImportProject::Type::MISSING; + + mPath = Path::getPathFromFilename(Path::fromNativeSeparators(filename)); + if (!mPath.empty() && !endsWith(mPath,'/')) + mPath += '/'; + if (endsWith(filename, ".json", 5)) { importCompileCommands(fin); return ImportProject::Type::COMPILE_DB; } else if (endsWith(filename, ".sln", 4)) { - std::string path(Path::getPathFromFilename(Path::fromNativeSeparators(filename))); - if (!path.empty() && !endsWith(path,'/')) - path += '/'; - importSln(fin,path); + importSln(fin,mPath); return ImportProject::Type::VS_SLN; } else if (endsWith(filename, ".vcxproj", 8)) { std::map variables; diff --git a/lib/importproject.h b/lib/importproject.h index 15de75f7b..a3dc4ea72 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -103,6 +103,8 @@ private: void importSln(std::istream &istr, const std::string &path); void importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories); void importBcb6Prj(const std::string &projectFilename); + + std::string mPath; }; /// @}