From ecb2bc4f04e5a6a71e19d4be651596cebbb83500 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Aug 2008 02:28:47 +0200 Subject: Modify pa_state_path() to take an additional argument for prepending the machine id to the file name. --- src/pulsecore/core-util.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/pulsecore/core-util.c') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 41bf42d3..d76abe83 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -1690,7 +1690,7 @@ char *pa_make_path_absolute(const char *p) { /* if fn is null return the PulseAudio run time path in s (~/.pulse) * if fn is non-null and starts with / return fn * otherwise append fn to the run time path and return it */ -static char *get_path(const char *fn, pa_bool_t rt) { +static char *get_path(const char *fn, pa_bool_t prependmid, pa_bool_t rt) { char *rtp; if (pa_is_path_absolute(fn)) @@ -1703,7 +1703,20 @@ static char *get_path(const char *fn, pa_bool_t rt) { if (fn) { char *r; - r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn); + + if (prependmid) { + char *mid; + + if (!(mid = pa_machine_id())) { + pa_xfree(rtp); + return NULL; + } + + r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s:%s", rtp, mid, fn); + pa_xfree(mid); + } else + r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn); + pa_xfree(rtp); return r; } else @@ -1711,11 +1724,11 @@ static char *get_path(const char *fn, pa_bool_t rt) { } char *pa_runtime_path(const char *fn) { - return get_path(fn, 1); + return get_path(fn, FALSE, TRUE); } -char *pa_state_path(const char *fn) { - return get_path(fn, 0); +char *pa_state_path(const char *fn, pa_bool_t appendmid) { + return get_path(fn, appendmid, FALSE); } /* Convert the string s to a signed integer in *ret_i */ -- cgit