[pulseaudio-commits] r2257 - in /branches/glitch-free/src/pulsecore: core-util.c core-util.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Apr 11 09:58:08 PDT 2008


Author: lennart
Date: Fri Apr 11 18:58:07 2008
New Revision: 2257

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2257&root=pulseaudio&view=rev
Log:
add new pa_get_state_dir() function, move pa_strnull() here

Modified:
    branches/glitch-free/src/pulsecore/core-util.c
    branches/glitch-free/src/pulsecore/core-util.h

Modified: branches/glitch-free/src/pulsecore/core-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/core-util.c?rev=2257&root=pulseaudio&r1=2256&r2=2257&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/core-util.c (original)
+++ branches/glitch-free/src/pulsecore/core-util.c Fri Apr 11 18:58:07 2008
@@ -1093,6 +1093,35 @@
     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

Modified: branches/glitch-free/src/pulsecore/core-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/core-util.h?rev=2257&root=pulseaudio&r1=2256&r2=2257&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/core-util.h (original)
+++ branches/glitch-free/src/pulsecore/core-util.h Fri Apr 11 18:58:07 2008
@@ -30,7 +30,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include <pulsecore/gccmacro.h>
+#include <pulse/gccmacro.h>
 #include <pulsecore/macro.h>
 
 struct timeval;
@@ -65,6 +65,10 @@
 
 static inline const char *pa_yes_no(pa_bool_t b) {
     return b ? "yes" : "no";
+}
+
+static inline const char *pa_strnull(const char *x) {
+    return x ? x : "(null)";
 }
 
 char *pa_split(const char *c, const char*delimiters, const char **state);
@@ -129,4 +133,6 @@
 
 char *pa_readlink(const char *p);
 
+char *pa_get_state_dir(void);
+
 #endif




More information about the pulseaudio-commits mailing list