path-util: introduce path_strv_contains() helper

it's like strv_contains() but uses path_equal() rather than streq() to
compare strings.
This commit is contained in:
Lennart Poettering 2020-01-07 16:24:33 +01:00
parent 125c7814fa
commit 3841fee822
2 changed files with 12 additions and 0 deletions

View File

@ -1115,3 +1115,13 @@ bool empty_or_root(const char *root) {
return root[strspn(root, "/")] == 0;
}
bool path_strv_contains(char **l, const char *path) {
char **i;
STRV_FOREACH(i, l)
if (path_equal(*i, path))
return true;
return false;
}

View File

@ -181,3 +181,5 @@ bool empty_or_root(const char *root);
static inline const char *empty_to_root(const char *path) {
return isempty(path) ? "/" : path;
}
bool path_strv_contains(char **l, const char *path);