summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-02-18 21:57:57 +0100
committerLennart Poettering <lennart@poettering.net>2009-02-18 21:57:57 +0100
commit7b8bed3e285f31537aa39f88600e59b749ac6508 (patch)
tree9d93e3fd292ae0170a587c52a8d921207c667084
parentd85ef716757f8c91ec1c97f87daf75e48bbe2de1 (diff)
introduce pa_realpath()
-rw-r--r--src/pulsecore/core-util.c25
-rw-r--r--src/pulsecore/core-util.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index d0ff7512..61f9a656 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2604,3 +2604,28 @@ char *pa_unescape(char *p) {
return p;
}
+
+char *pa_realpath(const char *path) {
+ char *r, *t;
+ pa_assert(path);
+
+ /* We want only abolsute paths */
+ if (path[0] != '/') {
+ errno = EINVAL;
+ return NULL;
+ }
+
+#ifndef __GLIBC__
+#error "It's not clear whether this system supports realpath(..., NULL) like GNU libc does. If it doesn't we need a private version of realpath() here."
+#endif
+
+ if (!(r = realpath(path, NULL)))
+ return NULL;
+
+ /* We copy this here in case our pa_xmalloc() is not implemented
+ * on top of libc malloc() */
+ t = pa_xstrdup(r);
+ pa_xfree(r);
+
+ return t;
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 8fd521b1..0ba33f31 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -221,4 +221,6 @@ char *pa_replace(const char*s, const char*a, const char *b);
char *pa_unescape(char *p);
+char *pa_realpath(const char *path);
+
#endif