[polypaudio-commits] r773 - in /trunk/src/polypcore: util.c util.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Apr 22 13:05:01 PDT 2006
Author: lennart
Date: Sat Apr 22 22:05:01 2006
New Revision: 773
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=773&root=polypaudio&view=rev
Log:
add new function pa_parent_dir()
Modified:
trunk/src/polypcore/util.c
trunk/src/polypcore/util.h
Modified: trunk/src/polypcore/util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/util.c?rev=773&root=polypaudio&r1=772&r2=773&view=diff
==============================================================================
--- trunk/src/polypcore/util.c (original)
+++ trunk/src/polypcore/util.c Sat Apr 22 22:05:01 2006
@@ -164,15 +164,25 @@
return -1;
}
+/* Return a newly allocated sting containing the parent directory of the specified file */
+char *pa_parent_dir(const char *fn) {
+ char *slash, *dir = pa_xstrdup(fn);
+
+ slash = (char*) pa_path_get_filename(dir);
+ if (slash == fn)
+ return NULL;
+
+ *(slash-1) = 0;
+ return dir;
+}
+
/* Creates a the parent directory of the specified path securely */
int pa_make_secure_parent_dir(const char *fn) {
int ret = -1;
- char *slash, *dir = pa_xstrdup(fn);
-
- slash = (char*) pa_path_get_filename(dir);
- if (slash == fn)
+ char *dir;
+
+ if (!(dir = pa_parent_dir(fn)))
goto finish;
- *(slash-1) = 0;
if (pa_make_secure_dir(dir) < 0)
goto finish;
@@ -183,7 +193,6 @@
pa_xfree(dir);
return ret;
}
-
/** Calls read() in a loop. Makes sure that as much as 'size' bytes,
* unless EOF is reached or an error occured */
Modified: trunk/src/polypcore/util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/util.h?rev=773&root=polypaudio&r1=772&r2=773&view=diff
==============================================================================
--- trunk/src/polypcore/util.h (original)
+++ trunk/src/polypcore/util.h Sat Apr 22 22:05:01 2006
@@ -55,6 +55,8 @@
const char *pa_path_get_filename(const char *p);
+char *pa_parent_dir(const char *fn);
+
struct timeval *pa_gettimeofday(struct timeval *tv);
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b);
int pa_timeval_cmp(const struct timeval *a, const struct timeval *b);
More information about the pulseaudio-commits
mailing list