diff options
| author | Dan Engelbrecht <[email protected]> | 2025-08-11 12:58:27 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-08-11 12:58:27 +0200 |
| commit | eeac0654ab8f9e3438f2331916261a0440286fbd (patch) | |
| tree | 56bd48ef8dedf91eeb25a7c26471742ab189874c /src/zenutil | |
| parent | Merge pull request #434 from ue-foundation/zs/put-overwrite-policy (diff) | |
| download | zen-eeac0654ab8f9e3438f2331916261a0440286fbd.tar.xz zen-eeac0654ab8f9e3438f2331916261a0440286fbd.zip | |
list build part content (#462)
- Feature: Added `zen build ls` option to list the content of a build part(s)
- Build source is specified using one of the following options
- `--cloud-url` cloud artifact URL to build
- `--host` or `--override-host`, `--namespace`, `--bucket` and `--buildid`
- `--filestorage`, `--namespace`, `--bucket` and `--buildid`
- `--build-part-name` to specify a particular build part(s) in the build
- `--wildcard` windows style wildcard (using * and ?) to match file paths to include
- `--exclude-wildcard` windows style wildcard (using * and ?) to match file paths to exclude. Applied after --wildcard include filter
- Improvement: Added `--quiet` option to zen `builds` commands to suppress non-essential output
Diffstat (limited to 'src/zenutil')
| -rw-r--r-- | src/zenutil/include/zenutil/wildcard.h | 13 | ||||
| -rw-r--r-- | src/zenutil/wildcard.cpp | 112 | ||||
| -rw-r--r-- | src/zenutil/zenutil.cpp | 2 |
3 files changed, 127 insertions, 0 deletions
diff --git a/src/zenutil/include/zenutil/wildcard.h b/src/zenutil/include/zenutil/wildcard.h new file mode 100644 index 000000000..9f402e100 --- /dev/null +++ b/src/zenutil/include/zenutil/wildcard.h @@ -0,0 +1,13 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <string_view> + +namespace zen { + +bool MatchWildcard(std::string_view Wildcard, std::string_view String, bool CaseSensitive); + +void wildcard_forcelink(); // internal + +} // namespace zen diff --git a/src/zenutil/wildcard.cpp b/src/zenutil/wildcard.cpp new file mode 100644 index 000000000..df69f6a5e --- /dev/null +++ b/src/zenutil/wildcard.cpp @@ -0,0 +1,112 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include <zencore/string.h> +#include <zenutil/wildcard.h> + +#if ZEN_WITH_TESTS +# include <zencore/testing.h> +#endif // ZEN_WITH_TESTS + +namespace zen { + +bool +MatchWildcard(std::string_view::const_iterator WildcardIt, + std::string_view::const_iterator WildcardEnd, + std::string_view::const_iterator StringIt, + std::string_view::const_iterator StringEnd) +{ + for (; WildcardIt != WildcardEnd; WildcardIt++) + { + switch (*WildcardIt) + { + case '?': + if (StringIt == StringEnd) + { + return false; + } + StringIt++; + break; + case '*': + { + if ((WildcardIt + 1) == WildcardEnd) + { + return true; + } + size_t Max = std::distance(StringIt, StringEnd); + for (size_t i = 0; i < Max; i++) + { + if (MatchWildcard(WildcardIt + 1, WildcardEnd, StringIt + i, StringEnd)) + { + return true; + } + } + return false; + } + default: + if (*StringIt != *WildcardIt) + { + return false; + } + ++StringIt; + } + } + return StringIt == StringEnd; +} + +bool +MatchWildcard(std::string_view Wildcard, std::string_view String, bool CaseSensitive) +{ + if (CaseSensitive) + { + return MatchWildcard(begin(Wildcard), end(Wildcard), begin(String), end(String)); + } + else + { + std::string LowercaseWildcard = ToLower(Wildcard); + std::string LowercaseString = ToLower(String); + std::string_view LowercaseWildcardView(LowercaseWildcard); + std::string_view LowercaseStringView(LowercaseString); + return MatchWildcard(begin(LowercaseWildcardView), + end(LowercaseWildcardView), + begin(LowercaseStringView), + end(LowercaseStringView)); + } +} + +#if ZEN_WITH_TESTS + +void +wildcard_forcelink() +{ +} + +TEST_CASE("Wildcard") +{ + CHECK(MatchWildcard("*.*", "normal.txt", true)); + CHECK(MatchWildcard("*.*", "normal.txt", false)); + + CHECK(!MatchWildcard("*.*", "normal", true)); + CHECK(!MatchWildcard("*.*", "normal", false)); + + CHECK(MatchWildcard("*", "hey/normal", true)); + CHECK(MatchWildcard("*", "hey/normal", false)); + + CHECK(MatchWildcard("hey/*.txt", "hey/normal.txt", true)); + CHECK(MatchWildcard("*/?ormal.txt", "hey/normal.txt", true)); + CHECK(!MatchWildcard("*/?rmal.txt", "hey/normal.txt", true)); + CHECK(MatchWildcard("*/?ormal.*", "hey/normal.txt", true)); + CHECK(MatchWildcard("*/?ormal", "hey/normal", true)); + + CHECK(MatchWildcard("hey/*.txt", "hey/normaL.txt", false)); + CHECK(MatchWildcard("*/?ormal.TXT", "hey/normal.txt", false)); + CHECK(MatchWildcard("*/?ORMAL.*", "hey/normal.txt", false)); + CHECK(MatchWildcard("*/?ormal", "HEY/normal", false)); + + CHECK(!MatchWildcard("hey/*.txt", "heY/normal.txt", true)); + CHECK(!MatchWildcard("*/?ormal.TXT", "hey/normal.txt", true)); + CHECK(!MatchWildcard("*/?ORMAL.*", "hey/normal.txt", true)); + CHECK(!MatchWildcard("*/?ormal", "hey/normaL", true)); +} + +#endif +} // namespace zen diff --git a/src/zenutil/zenutil.cpp b/src/zenutil/zenutil.cpp index fe23b00c1..37b229c49 100644 --- a/src/zenutil/zenutil.cpp +++ b/src/zenutil/zenutil.cpp @@ -9,6 +9,7 @@ # include <zenutil/chunkedfile.h> # include <zenutil/commandlineoptions.h> # include <zenutil/parallelwork.h> +# include <zenutil/wildcard.h> namespace zen { @@ -21,6 +22,7 @@ zenutil_forcelinktests() chunkedfile_forcelink(); commandlineoptions_forcelink(); parallellwork_forcelink(); + wildcard_forcelink(); } } // namespace zen |