summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-04-11 16:58:07 +0000
committerLennart Poettering <lennart@poettering.net>2008-04-11 16:58:07 +0000
commitcdb273de904a0a66fee2c0dc0c164455f8c035ac (patch)
treebefe6d8bdd25b184cee779521a0bc7b98bc90aa0 /src/pulsecore/core-util.c
parentdcf71734892ed6f8076a6ae37718fa02c750be7a (diff)
add new pa_get_state_dir() function, move pa_strnull() here
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2257 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r--src/pulsecore/core-util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 61d04c2d..28885b2c 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1093,6 +1093,35 @@ int pa_unlock_lockfile(const char *fn, int fd) {
return r;
}
+char *pa_get_state_dir(void) {
+ const char *e;
+ char *d;
+
+ if ((e = getenv("PULSE_STATE_PATH")))
+ d = pa_xstrdup(e);
+ else {
+ char h[PATH_MAX];
+
+ if (!pa_get_home_dir(h, sizeof(h))) {
+ pa_log_error("Failed to get home directory.");
+ return NULL;
+ }
+
+ d = pa_sprintf_malloc("%s/.pulse", h);
+ }
+
+ mkdir(d, 0755);
+
+ if (access(d, W_OK) == 0)
+ return d;
+
+ pa_log_error("Failed to set up state directory %s", d);
+
+ pa_xfree(d);
+
+ return NULL;
+}
+
/* Try to open a configuration file. If "env" is specified, open the
* value of the specified environment variable. Otherwise look for a
* file "local" in the home directory or a file "global" in global