summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-18 16:54:14 +0100
committerDavid Robillard <d@drobilla.net>2020-12-18 17:38:43 +0100
commitb58174f0ebe31fb56fe891bfbcf10979079053e3 (patch)
treee951d28c07373cb58bcd1ab901a80d3d30fe64c0 /src
parentb8c3fa9e5476d5d6bb5413f9d52d406475f9e900 (diff)
downloadlilv-b58174f0ebe31fb56fe891bfbcf10979079053e3.tar.gz
lilv-b58174f0ebe31fb56fe891bfbcf10979079053e3.tar.bz2
lilv-b58174f0ebe31fb56fe891bfbcf10979079053e3.zip
Add lilv_path_absolute_child()
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c10
-rw-r--r--src/filesystem.h9
2 files changed, 19 insertions, 0 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index 0ec9802..0482336 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -135,6 +135,16 @@ lilv_path_absolute(const char* path)
}
char*
+lilv_path_absolute_child(const char* path, const char* parent)
+{
+ if (lilv_path_is_absolute(path)) {
+ return lilv_strdup(path);
+ }
+
+ return lilv_path_join(parent, path);
+}
+
+char*
lilv_path_relative_to(const char* path, const char* base)
{
const size_t path_len = strlen(path);
diff --git a/src/filesystem.h b/src/filesystem.h
index 319dd49..f888f5f 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -43,6 +43,15 @@ char*
lilv_path_absolute(const char* path);
/**
+ Return `path` as an absolute path relative to `parent`.
+
+ If `path` is absolute, an identical copy of it is returned. Otherwise, the
+ returned path is relative to `parent`.
+*/
+char*
+lilv_path_absolute_child(const char* path, const char* parent);
+
+/**
Return `path` relative to `base` if possible.
If `path` is not within `base`, a copy is returned. Otherwise, an