summaryrefslogtreecommitdiff
path: root/src/shared/path-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 14:47:31 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 15:08:42 -0400
commit0c6ea3a4e2ac3f350dcb58e8f08bb74b030cd624 (patch)
tree562a17aa7a48741002001b59b5ad04a428890217 /src/shared/path-util.c
parent60731f32f1d25070ed7559bdd64d65e7462a4df6 (diff)
Add utility function to append root to path
Diffstat (limited to 'src/shared/path-util.c')
-rw-r--r--src/shared/path-util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 6b13f0254..5bc5012fe 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -435,6 +435,22 @@ bool path_equal(const char *a, const char *b) {
}
}
+char* path_join(const char *root, const char *path, const char *rest) {
+ assert(path);
+
+ if (!isempty(root))
+ return strjoin(root, "/",
+ path[0] == '/' ? path+1 : path,
+ rest ? "/" : NULL,
+ rest && rest[0] == '/' ? rest+1 : rest,
+ NULL);
+ else
+ return strjoin(path,
+ rest ? "/" : NULL,
+ rest && rest[0] == '/' ? rest+1 : rest,
+ NULL);
+}
+
int path_is_mount_point(const char *t, bool allow_symlink) {
union file_handle_union h = {