core-util: implement pa_maybe_prefix_path()

This commit is contained in:
Lennart Poettering 2009-06-17 03:13:59 +02:00
parent 7fa05bea7e
commit 0fa1ddf838
2 changed files with 11 additions and 0 deletions

View file

@ -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);
}

View file

@ -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