summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/util.c b/util.c
index f752a248ec..7c3935353c 100644
--- a/util.c
+++ b/util.c
@@ -443,3 +443,28 @@ char *file_name_from_path(const char *p) {
return (char*) p;
}
+
+bool path_is_absolute(const char *p) {
+ assert(p);
+
+ return p[0] == '/';
+}
+
+bool is_path(const char *p) {
+
+ return !!strchr(p, '/');
+}
+
+char *path_make_absolute(const char *p, const char *prefix) {
+ char *r;
+
+ assert(p);
+
+ if (path_is_absolute(p) || !prefix)
+ return strdup(p);
+
+ if (asprintf(&r, "%s/%s", prefix, p) < 0)
+ return NULL;
+
+ return r;
+}