path-util: Reduce transitive includes
This commit is contained in:
committed by
Yu Watanabe
parent
fda652117e
commit
d9ccf6b349
@@ -22,6 +22,13 @@
|
||||
#include "strv.h"
|
||||
#include "time-util.h"
|
||||
|
||||
bool is_path(const char *p) {
|
||||
if (!p) /* A NULL pointer is definitely not a path */
|
||||
return false;
|
||||
|
||||
return strchr(p, '/');
|
||||
}
|
||||
|
||||
int path_split_and_make_absolute(const char *p, char ***ret) {
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
int r;
|
||||
@@ -345,6 +352,10 @@ char** path_strv_resolve_uniq(char **l, const char *root) {
|
||||
return strv_uniq(l);
|
||||
}
|
||||
|
||||
char* skip_leading_slash(const char *p) {
|
||||
return skip_leading_chars(p, "/");
|
||||
}
|
||||
|
||||
char* path_simplify_full(char *path, PathSimplifyFlags flags) {
|
||||
bool add_slash = false, keep_trailing_slash, absolute, beginning = true;
|
||||
char *f = path;
|
||||
@@ -406,6 +417,22 @@ char* path_simplify_full(char *path, PathSimplifyFlags flags) {
|
||||
return path;
|
||||
}
|
||||
|
||||
int path_simplify_alloc(const char *path, char **ret) {
|
||||
assert(ret);
|
||||
|
||||
if (!path) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *t = strdup(path);
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = path_simplify(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* path_startswith_full(const char *path, const char *prefix, bool accept_dot_dot) {
|
||||
assert(path);
|
||||
assert(prefix);
|
||||
@@ -1361,6 +1388,10 @@ bool empty_or_root(const char *path) {
|
||||
return path_equal(path, "/");
|
||||
}
|
||||
|
||||
const char* empty_to_root(const char *path) {
|
||||
return isempty(path) ? "/" : path;
|
||||
}
|
||||
|
||||
bool path_strv_contains(char * const *l, const char *path) {
|
||||
assert(path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user