diff options
Diffstat (limited to 'src/zenutil')
| -rw-r--r-- | src/zenutil/include/zenutil/wildcard.h | 5 | ||||
| -rw-r--r-- | src/zenutil/wildcard.cpp | 33 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/zenutil/include/zenutil/wildcard.h b/src/zenutil/include/zenutil/wildcard.h index 9f402e100..db2d4bda0 100644 --- a/src/zenutil/include/zenutil/wildcard.h +++ b/src/zenutil/include/zenutil/wildcard.h @@ -8,6 +8,11 @@ namespace zen { bool MatchWildcard(std::string_view Wildcard, std::string_view String, bool CaseSensitive); +bool IncludePath(std::span<const std::string> IncludeWildcards, + std::span<const std::string> ExcludeWildcards, + const std::string& Path, + bool CaseSensitive); + void wildcard_forcelink(); // internal } // namespace zen diff --git a/src/zenutil/wildcard.cpp b/src/zenutil/wildcard.cpp index d9d5b384f..7a44c0498 100644 --- a/src/zenutil/wildcard.cpp +++ b/src/zenutil/wildcard.cpp @@ -78,6 +78,39 @@ MatchWildcard(std::string_view Wildcard, std::string_view String, bool CaseSensi } } +bool +IncludePath(std::span<const std::string> IncludeWildcards, + std::span<const std::string> ExcludeWildcards, + const std::string& Path, + bool CaseSensitive) +{ + bool IncludePath = true; + if (!IncludeWildcards.empty()) + { + IncludePath = false; + for (const std::string& IncludeWildcard : IncludeWildcards) + { + if (MatchWildcard(IncludeWildcard, Path, CaseSensitive)) + { + IncludePath = true; + break; + } + } + if (!IncludePath) + { + return false; + } + } + for (const std::string& ExcludeWildcard : ExcludeWildcards) + { + if (MatchWildcard(ExcludeWildcard, Path, CaseSensitive)) + { + return false; + } + } + return true; +} + #if ZEN_WITH_TESTS void |