From 0fa1ddf8380d6b86bd7e911ac6db7771dcb14dd6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 03:13:59 +0200 Subject: core-util: implement pa_maybe_prefix_path() --- src/pulsecore/core-util.c | 9 +++++++++ src/pulsecore/core-util.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index e39adb12..a71ba0b0 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2768,3 +2768,12 @@ char **pa_split_spaces_strv(const char *s) { t[i] = NULL; return t; } + +char* pa_maybe_prefix_path(const char *path, const char *prefix) { + pa_assert(path); + + if (pa_is_path_absolute(path)) + return pa_xstrdup(path); + + return pa_sprintf_malloc("%s" PA_PATH_SEP "%s", prefix, path); +} diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index d88b7cbb..b841edbb 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -237,4 +237,6 @@ static inline void pa_xstrfreev(char **a) { char **pa_split_spaces_strv(const char *s); +char* pa_maybe_prefix_path(const char *path, const char *prefix); + #endif -- cgit