mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
introduce pa_realpath()
This commit is contained in:
parent
d85ef71675
commit
7b8bed3e28
2 changed files with 27 additions and 0 deletions
|
|
@ -2604,3 +2604,28 @@ char *pa_unescape(char *p) {
|
|||
|
||||
return p;
|
||||
}
|
||||
|
||||
char *pa_realpath(const char *path) {
|
||||
char *r, *t;
|
||||
pa_assert(path);
|
||||
|
||||
/* We want only abolsute paths */
|
||||
if (path[0] != '/') {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef __GLIBC__
|
||||
#error "It's not clear whether this system supports realpath(..., NULL) like GNU libc does. If it doesn't we need a private version of realpath() here."
|
||||
#endif
|
||||
|
||||
if (!(r = realpath(path, NULL)))
|
||||
return NULL;
|
||||
|
||||
/* We copy this here in case our pa_xmalloc() is not implemented
|
||||
* on top of libc malloc() */
|
||||
t = pa_xstrdup(r);
|
||||
pa_xfree(r);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,4 +221,6 @@ char *pa_replace(const char*s, const char*a, const char *b);
|
|||
|
||||
char *pa_unescape(char *p);
|
||||
|
||||
char *pa_realpath(const char *path);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue