aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zen/cmds/builds_cmd.cpp31
-rw-r--r--src/zencore/include/zencore/string.h18
-rw-r--r--src/zenremotestore/builds/buildinspect.cpp5
-rw-r--r--src/zenremotestore/builds/buildupdatefolder.cpp3
-rw-r--r--src/zenremotestore/builds/builduploadfolder.cpp5
-rw-r--r--src/zenutil/filesystemutils.cpp3
6 files changed, 45 insertions, 20 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp
index 84d8424aa..775c3d283 100644
--- a/src/zen/cmds/builds_cmd.cpp
+++ b/src/zen/cmds/builds_cmd.cpp
@@ -1025,19 +1025,22 @@ void
BuildsSubCmdBase::ParseExcludeFolderAndExtension(std::vector<std::string>& OutExcludeFolders,
std::vector<std::string>& OutExcludeExtensions)
{
- auto SplitAndAppendExclusion = [](const std::string_view Input, std::vector<std::string>& Output) {
- ForEachStrTok(Input, ";,", [&Output](std::string_view Exclusion) {
- if (!Exclusion.empty())
- {
- std::string CleanExclusion(ToLower(Exclusion));
- if (CleanExclusion.length() > 2 && CleanExclusion.front() == '"' && CleanExclusion.back() == '"')
- {
- CleanExclusion = CleanExclusion.substr(1, CleanExclusion.length() - 2);
- }
- Output.emplace_back(std::move(CleanExclusion));
- }
- return true;
- });
+ constexpr AsciiSet Whitespace(" ");
+ auto SplitAndAppendExclusion = [&Whitespace](const std::string_view Input, std::vector<std::string>& Output) {
+ ForEachStrTok(Input, ";,", [&Output, &Whitespace](std::string_view Exclusion) {
+ Exclusion = AsciiSet::TrimPrefixWith(Exclusion, Whitespace);
+ Exclusion = AsciiSet::TrimSuffixWith(Exclusion, Whitespace);
+ if (!Exclusion.empty())
+ {
+ std::string CleanExclusion(ToLower(Exclusion));
+ if (CleanExclusion.length() > 2 && CleanExclusion.front() == '"' && CleanExclusion.back() == '"')
+ {
+ CleanExclusion = CleanExclusion.substr(1, CleanExclusion.length() - 2);
+ }
+ Output.emplace_back(std::move(CleanExclusion));
+ }
+ return true;
+ });
};
SplitAndAppendExclusion(m_Config.ExcludeFolders, OutExcludeFolders);
@@ -2546,7 +2549,7 @@ BuildsTestSubCmd::Run(const ZenCliOptions& /*GlobalOptions*/)
std::string RelativePath = std::filesystem::relative(AbsolutePath, Path).generic_string();
for (const std::string& ExcludeFolder : ExcludeFolders)
{
- if (RelativePath.starts_with(ExcludeFolder))
+ if (StrCaseStartsWith(RelativePath, ExcludeFolder))
{
if (RelativePath.length() == ExcludeFolder.length())
{
diff --git a/src/zencore/include/zencore/string.h b/src/zencore/include/zencore/string.h
index 7ca2afc69..fded960f3 100644
--- a/src/zencore/include/zencore/string.h
+++ b/src/zencore/include/zencore/string.h
@@ -1039,6 +1039,24 @@ StrCaseCompare(std::string_view Lhs, std::string_view Rhs)
return Result;
}
+inline bool
+StrCaseEquals(std::string_view Lhs, std::string_view Rhs)
+{
+ return StrCaseCompare(Lhs, Rhs) == 0;
+}
+
+inline bool
+StrCaseStartsWith(std::string_view Str, std::string_view Prefix)
+{
+ return Str.size() >= Prefix.size() && StrCaseCompare(Str.data(), Prefix.data(), Prefix.size()) == 0;
+}
+
+inline bool
+StrCaseEndsWith(std::string_view Str, std::string_view Suffix)
+{
+ return Str.size() >= Suffix.size() && StrCaseCompare(Str.data() + (Str.size() - Suffix.size()), Suffix.data(), Suffix.size()) == 0;
+}
+
/**
* @brief
* Helper function to implement case sensitive spaceship operator for strings.
diff --git a/src/zenremotestore/builds/buildinspect.cpp b/src/zenremotestore/builds/buildinspect.cpp
index 1af9e20af..86f2cfd75 100644
--- a/src/zenremotestore/builds/buildinspect.cpp
+++ b/src/zenremotestore/builds/buildinspect.cpp
@@ -5,6 +5,7 @@
#include <zencore/compactbinarybuilder.h>
#include <zencore/fmtutils.h>
#include <zencore/scopeguard.h>
+#include <zencore/string.h>
#include <zencore/timer.h>
#include <zencore/trace.h>
#include <zenremotestore/builds/buildcontent.h>
@@ -298,7 +299,7 @@ DiffFolders(ProgressBase& Progress,
auto IsAcceptedFolder = [ExcludeFolders](const std::string_view& RelativePath) -> bool {
for (const std::string& ExcludeFolder : ExcludeFolders)
{
- if (RelativePath.starts_with(ExcludeFolder))
+ if (StrCaseStartsWith(RelativePath, ExcludeFolder))
{
if (RelativePath.length() == ExcludeFolder.length())
{
@@ -316,7 +317,7 @@ DiffFolders(ProgressBase& Progress,
auto IsAcceptedFile = [ExcludeExtensions](const std::string_view& RelativePath, uint64_t, uint32_t) -> bool {
for (const std::string& ExcludeExtension : ExcludeExtensions)
{
- if (RelativePath.ends_with(ExcludeExtension))
+ if (StrCaseEndsWith(RelativePath, ExcludeExtension))
{
return false;
}
diff --git a/src/zenremotestore/builds/buildupdatefolder.cpp b/src/zenremotestore/builds/buildupdatefolder.cpp
index 443ab957e..ebef12900 100644
--- a/src/zenremotestore/builds/buildupdatefolder.cpp
+++ b/src/zenremotestore/builds/buildupdatefolder.cpp
@@ -6,6 +6,7 @@
#include <zencore/fmtutils.h>
#include <zencore/parallelwork.h>
#include <zencore/scopeguard.h>
+#include <zencore/string.h>
#include <zencore/trace.h>
#include <zenremotestore/builds/buildcontent.h>
#include <zenremotestore/builds/buildmanifest.h>
@@ -4195,7 +4196,7 @@ VerifyFolder(ProgressBase& Progress,
auto IsAcceptedFolder = [ExcludeFolders = ExcludeFolders](const std::string_view& RelativePath) -> bool {
for (const std::string& ExcludeFolder : ExcludeFolders)
{
- if (RelativePath.starts_with(ExcludeFolder))
+ if (StrCaseStartsWith(RelativePath, ExcludeFolder))
{
if (RelativePath.length() == ExcludeFolder.length())
{
diff --git a/src/zenremotestore/builds/builduploadfolder.cpp b/src/zenremotestore/builds/builduploadfolder.cpp
index b536ae464..433d24619 100644
--- a/src/zenremotestore/builds/builduploadfolder.cpp
+++ b/src/zenremotestore/builds/builduploadfolder.cpp
@@ -7,6 +7,7 @@
#include <zencore/fmtutils.h>
#include <zencore/parallelwork.h>
#include <zencore/scopeguard.h>
+#include <zencore/string.h>
#include <zencore/trace.h>
#include <zenremotestore/builds/buildcontent.h>
#include <zenremotestore/builds/buildmanifest.h>
@@ -446,7 +447,7 @@ BuildsOperationUploadFolder::IsAcceptedFolder(const std::string_view& RelativePa
{
for (const std::string& ExcludeFolder : m_Options.ExcludeFolders)
{
- if (RelativePath.starts_with(ExcludeFolder))
+ if (StrCaseStartsWith(RelativePath, ExcludeFolder))
{
if (RelativePath.length() == ExcludeFolder.length())
{
@@ -470,7 +471,7 @@ BuildsOperationUploadFolder::IsAcceptedFile(const std::string_view& RelativePath
}
for (const std::string& ExcludeExtension : m_Options.ExcludeExtensions)
{
- if (RelativePath.ends_with(ExcludeExtension))
+ if (StrCaseEndsWith(RelativePath, ExcludeExtension))
{
return false;
}
diff --git a/src/zenutil/filesystemutils.cpp b/src/zenutil/filesystemutils.cpp
index f8f7bfb18..3d02a8a45 100644
--- a/src/zenutil/filesystemutils.cpp
+++ b/src/zenutil/filesystemutils.cpp
@@ -6,6 +6,7 @@
#include <zencore/fmtutils.h>
#include <zencore/parallelwork.h>
#include <zencore/scopeguard.h>
+#include <zencore/string.h>
#include <zencore/timer.h>
#include <zencore/trace.h>
@@ -424,7 +425,7 @@ CleanDirectory(
const std::string DirectoryString = DirectoryName.string();
for (const std::string_view ExcludeDirectory : ExcludeDirectories)
{
- if (DirectoryString == ExcludeDirectory)
+ if (StrCaseEquals(DirectoryString, ExcludeDirectory))
{
return false;
}