mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
core-util: Add pa_append_to_home_dir()
This commit is contained in:
parent
71ead4989a
commit
50042da434
3 changed files with 20 additions and 5 deletions
|
|
@ -142,14 +142,11 @@ static char *normalize_path(const char *fn) {
|
|||
#else
|
||||
if (strlen(fn) < 3 || !IsCharAlpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') {
|
||||
#endif
|
||||
char *homedir, *s;
|
||||
char *s;
|
||||
|
||||
if (!(homedir = pa_get_home_dir_malloc()))
|
||||
if (pa_append_to_home_dir(fn, &s) < 0)
|
||||
return NULL;
|
||||
|
||||
s = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", homedir, fn);
|
||||
pa_xfree(homedir);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1653,6 +1653,23 @@ char *pa_get_home_dir_malloc(void) {
|
|||
return homedir;
|
||||
}
|
||||
|
||||
int pa_append_to_home_dir(const char *path, char **_r) {
|
||||
char *home_dir;
|
||||
|
||||
pa_assert(path);
|
||||
pa_assert(_r);
|
||||
|
||||
home_dir = pa_get_home_dir_malloc();
|
||||
if (!home_dir) {
|
||||
pa_log("Failed to get home directory.");
|
||||
return -PA_ERR_NOENTITY;
|
||||
}
|
||||
|
||||
*_r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", home_dir, path);
|
||||
pa_xfree(home_dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *pa_get_binary_name_malloc(void) {
|
||||
char *t;
|
||||
size_t allocated = 128;
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ char* pa_find_config_file(const char *global, const char *local, const char *env
|
|||
char *pa_get_runtime_dir(void);
|
||||
char *pa_get_state_dir(void);
|
||||
char *pa_get_home_dir_malloc(void);
|
||||
int pa_append_to_home_dir(const char *path, char **_r);
|
||||
char *pa_get_binary_name_malloc(void);
|
||||
char *pa_runtime_path(const char *fn);
|
||||
char *pa_state_path(const char *fn, bool prepend_machine_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue