28inline auto wildcardMatch(
const char *text,
const char *pattern) ->
bool {
29 while (*pattern !=
'\0') {
34 const char *p = pattern;
36 const char *q = p + 1;
37 bool isRecur = (q[0] ==
'*' && q[1] ==
'*') ||
38 (q[0] ==
'.' && q[1] ==
'.' && q[2] ==
'.');
46 if (p[0] ==
'*' && p[1] ==
'*') {
48 }
else if (p[0] ==
'.' && p[1] ==
'.' && p[2] ==
'.') {
53 const char *afterRecur = p + recurLen;
54 bool hasTrail = (*afterRecur ==
'.');
55 const char *rest = hasTrail ? afterRecur + 1 : afterRecur;
57 if (hasLead && hasTrail) {
67 while (*text !=
'\0') {
103 while (*text !=
'\0') {
124 if (*pattern ==
'*') {
126 const char *rest = pattern + 1;
131 if (*text ==
'\0' || *text ==
'.') {
138 if (*pattern ==
'?') {
140 if (*text ==
'\0' || *text ==
'.') {
148 if (*pattern != *text) {
154 return *text ==
'\0';
161inline auto pathInScope(std::string_view path, std::string_view scope) ->
bool {
162 if (path.size() < scope.size() || path.substr(0, scope.size()) != scope) {
165 return path.size() == scope.size() || path[scope.size()] ==
'.';
Definition FormatBuffer.hpp:9
auto wildcardMatch(const char *text, const char *pattern) -> bool
Definition Wildcard.hpp:28
auto pathInScope(std::string_view path, std::string_view scope) -> bool
Definition Wildcard.hpp:161