Add noextract configuration option

Closes #208
Fixes #165
This commit is contained in:
Duncan Overbruck
2020-01-18 14:49:59 +01:00
parent ef9260a16e
commit 6794077efd
10 changed files with 269 additions and 3 deletions

View File

@ -648,3 +648,27 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt)
return res;
}
bool
xbps_patterns_match(xbps_array_t patterns, const char *path)
{
bool match = false;
if (patterns == NULL)
return false;
for (unsigned int i = 0; i < xbps_array_count(patterns); i++) {
const char *pattern = NULL;
bool negate = false;
if (!xbps_array_get_cstring_nocopy(patterns, i, &pattern))
continue;
if (pattern == NULL)
continue;
if ((negate = *pattern == '!') || *pattern == '\\')
pattern++;
if (fnmatch(pattern, path, 0) == 0)
match = !negate;
}
return match;
}