mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 02:21:44 +03:00
path-util: port path_join() over to path_join_many()
We should probably drop path_join() entirely in the long run (and then rename path_join_many() to it?), but for now let's make one a wrapper for the other.
This commit is contained in:
parent
cd8194a389
commit
61e0111df9
@ -481,20 +481,6 @@ bool path_equal_or_files_same(const char *a, const char *b, int flags) {
|
||||
return path_equal(a, b) || files_same(a, b, flags) > 0;
|
||||
}
|
||||
|
||||
char* path_join(const char *root, const char *path, const char *rest) {
|
||||
assert(path);
|
||||
|
||||
if (!isempty(root))
|
||||
return strjoin(root, endswith(root, "/") ? "" : "/",
|
||||
path[0] == '/' ? path+1 : path,
|
||||
rest ? (endswith(path, "/") ? "" : "/") : NULL,
|
||||
rest && rest[0] == '/' ? rest+1 : rest);
|
||||
else
|
||||
return strjoin(path,
|
||||
rest ? (endswith(path, "/") ? "" : "/") : NULL,
|
||||
rest && rest[0] == '/' ? rest+1 : rest);
|
||||
}
|
||||
|
||||
char* path_join_many_internal(const char *first, ...) {
|
||||
char *joined, *q;
|
||||
const char *p;
|
||||
|
@ -49,9 +49,13 @@ char* path_startswith(const char *path, const char *prefix) _pure_;
|
||||
int path_compare(const char *a, const char *b) _pure_;
|
||||
bool path_equal(const char *a, const char *b) _pure_;
|
||||
bool path_equal_or_files_same(const char *a, const char *b, int flags);
|
||||
char* path_join(const char *root, const char *path, const char *rest);
|
||||
char* path_join_many_internal(const char *first, ...) _sentinel_;
|
||||
#define path_join_many(x, ...) path_join_many_internal(x, __VA_ARGS__, NULL)
|
||||
static inline char* path_join(const char *root, const char *path, const char *rest) {
|
||||
assert(path);
|
||||
|
||||
return path_join_many(strempty(root), path, rest);
|
||||
}
|
||||
|
||||
char* path_simplify(char *path, bool kill_dots);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user