mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
add new function pa_parent_dir()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@773 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
513df3b9f8
commit
a4fedcf2dc
2 changed files with 16 additions and 5 deletions
|
|
@ -164,15 +164,25 @@ fail:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates a the parent directory of the specified path securely */
|
/* Return a newly allocated sting containing the parent directory of the specified file */
|
||||||
int pa_make_secure_parent_dir(const char *fn) {
|
char *pa_parent_dir(const char *fn) {
|
||||||
int ret = -1;
|
|
||||||
char *slash, *dir = pa_xstrdup(fn);
|
char *slash, *dir = pa_xstrdup(fn);
|
||||||
|
|
||||||
slash = (char*) pa_path_get_filename(dir);
|
slash = (char*) pa_path_get_filename(dir);
|
||||||
if (slash == fn)
|
if (slash == fn)
|
||||||
goto finish;
|
return NULL;
|
||||||
|
|
||||||
*(slash-1) = 0;
|
*(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 *dir;
|
||||||
|
|
||||||
|
if (!(dir = pa_parent_dir(fn)))
|
||||||
|
goto finish;
|
||||||
|
|
||||||
if (pa_make_secure_dir(dir) < 0)
|
if (pa_make_secure_dir(dir) < 0)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
@ -184,7 +194,6 @@ finish:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Calls read() in a loop. Makes sure that as much as 'size' bytes,
|
/** Calls read() in a loop. Makes sure that as much as 'size' bytes,
|
||||||
* unless EOF is reached or an error occured */
|
* unless EOF is reached or an error occured */
|
||||||
ssize_t pa_loop_read(int fd, void*data, size_t size) {
|
ssize_t pa_loop_read(int fd, void*data, size_t size) {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ char *pa_get_home_dir(char *s, size_t l);
|
||||||
|
|
||||||
const char *pa_path_get_filename(const char *p);
|
const char *pa_path_get_filename(const char *p);
|
||||||
|
|
||||||
|
char *pa_parent_dir(const char *fn);
|
||||||
|
|
||||||
struct timeval *pa_gettimeofday(struct timeval *tv);
|
struct timeval *pa_gettimeofday(struct timeval *tv);
|
||||||
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b);
|
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);
|
int pa_timeval_cmp(const struct timeval *a, const struct timeval *b);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue