logic: paths that are automatically filled by the project setup wizard will be made relative if they are shorter if the absolute paths
This commit is contained in:
@@ -57,33 +57,6 @@ std::set<FilePath> FileManager::getAllSourceFilePaths() const
|
||||
return m_allSourceFilePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getAllSourceFilePathsRelative(const FilePath& baseDirectory) const
|
||||
{
|
||||
std::set<FilePath> absolutePaths;
|
||||
for (const FilePath& path: getAllSourceFilePaths())
|
||||
{
|
||||
if (baseDirectory.exists())
|
||||
{
|
||||
absolutePaths.insert(path.getRelativeTo(baseDirectory));
|
||||
}
|
||||
else
|
||||
{
|
||||
absolutePaths.insert(path);
|
||||
}
|
||||
}
|
||||
return absolutePaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> FileManager::makeCanonical(const std::vector<FilePath>& filePaths)
|
||||
{
|
||||
std::vector<FilePath> ret;
|
||||
for (const FilePath& filePath: filePaths)
|
||||
{
|
||||
ret.push_back(filePath.getCanonical());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FileManager::isExcluded(const FilePath& filePath) const
|
||||
{
|
||||
for (const FilePathFilter& filter : m_excludeFilters)
|
||||
|
||||
@@ -29,10 +29,8 @@ public:
|
||||
|
||||
// returns a list of paths to all files that reside in the non-excluded source paths
|
||||
std::set<FilePath> getAllSourceFilePaths() const;
|
||||
std::set<FilePath> getAllSourceFilePathsRelative(const FilePath& baseDirectory) const;
|
||||
|
||||
private:
|
||||
std::vector<FilePath> makeCanonical(const std::vector<FilePath>& filePaths);
|
||||
bool isExcluded(const FilePath& filePath) const;
|
||||
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
|
||||
@@ -26,3 +26,22 @@ std::vector<FilePath> utility::getTopLevelPaths(const std::set<FilePath>& paths)
|
||||
|
||||
return topLevelPaths;
|
||||
}
|
||||
|
||||
FilePath utility::getAsRelativeIfShorter(const FilePath& absolutePath, const FilePath& baseDirectory)
|
||||
{
|
||||
if (!baseDirectory.empty())
|
||||
{
|
||||
const FilePath relativePath = absolutePath.getRelativeTo(baseDirectory);
|
||||
if (relativePath.wstr().size() < absolutePath.wstr().size())
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
}
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
std::vector<FilePath> utility::getAsRelativeIfShorter(const std::vector<FilePath>& absolutePaths, const FilePath& baseDirectory)
|
||||
{
|
||||
return utility::convert<FilePath, FilePath>(absolutePaths, [&](const FilePath& path) { return getAsRelativeIfShorter(path, baseDirectory); });
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace utility
|
||||
{
|
||||
std::vector<FilePath> getTopLevelPaths(const std::vector<FilePath>& paths);
|
||||
std::vector<FilePath> getTopLevelPaths(const std::set<FilePath>& paths);
|
||||
|
||||
FilePath getAsRelativeIfShorter(const FilePath& absolutePath, const FilePath& baseDirectory);
|
||||
std::vector<FilePath> getAsRelativeIfShorter(const std::vector<FilePath>& absolutePaths, const FilePath& baseDirectory);
|
||||
}
|
||||
|
||||
#endif // UTILITY_FILE_H
|
||||
|
||||
Reference in New Issue
Block a user