Made .lmsignore more like .gitignore, fixes #486
This commit is contained in:
@@ -21,8 +21,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "core/String.hpp"
|
||||
|
||||
@@ -35,22 +33,13 @@ namespace lms::core::pathUtils
|
||||
return (std::find(std::cbegin(supportedExtensions), std::cend(supportedExtensions), extension) != std::cend(supportedExtensions));
|
||||
}
|
||||
|
||||
bool isPathInRootPath(const std::filesystem::path& path, const std::filesystem::path& rootPathArg, const std::filesystem::path* excludeDirFileName)
|
||||
bool isPathInRootPath(const std::filesystem::path& path, const std::filesystem::path& rootPathArg)
|
||||
{
|
||||
std::filesystem::path curPath{ path };
|
||||
std::filesystem::path rootPath{ rootPathArg.has_filename() ? rootPathArg : rootPathArg.parent_path() };
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (excludeDirFileName && !excludeDirFileName->empty())
|
||||
{
|
||||
assert(!excludeDirFileName->has_parent_path());
|
||||
|
||||
std::error_code ec;
|
||||
if (std::filesystem::exists(curPath / *excludeDirFileName, ec))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curPath == rootPath)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -29,9 +29,8 @@ namespace lms::core::pathUtils
|
||||
// Check if file's extension is one of provided extensions
|
||||
bool hasFileAnyExtension(const std::filesystem::path& file, std::span<const std::filesystem::path> extensions);
|
||||
|
||||
// Check if a path is within a directory (excludeDirFileName is a relative can be used to exclude a whole directory and its subdirectory, must not have parent_path)
|
||||
// Caller responsibility to call with normalized paths
|
||||
bool isPathInRootPath(const std::filesystem::path& path, const std::filesystem::path& rootPath, const std::filesystem::path* excludeDirFileName = {});
|
||||
// Check if a path is within a directory. Caller responsibility to call with normalized paths.
|
||||
bool isPathInRootPath(const std::filesystem::path& path, const std::filesystem::path& rootPath);
|
||||
|
||||
std::filesystem::path getLongestCommonPath(const std::filesystem::path& path1, const std::filesystem::path& path2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user