mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
cli-command: Replace config dir with toplevel for .include on win32
This makes the behaviour match pa_{open,find}_config_file by
replacing PA_DEFAULT_CONFIG_DIR with the toplevel.
This fixes the hardcoded paths for {default,system}.pa.d introduced
in 45abd0b43c (!361).
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/545>
This commit is contained in:
parent
4ec89c27c9
commit
a238a58186
1 changed files with 22 additions and 4 deletions
|
|
@ -2084,20 +2084,34 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
|
||||||
|
|
||||||
if (l == sizeof(META_INCLUDE)-1 && !strncmp(cs, META_INCLUDE, l)) {
|
if (l == sizeof(META_INCLUDE)-1 && !strncmp(cs, META_INCLUDE, l)) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *filename = cs+l+strspn(cs+l, whitespace);
|
const char *fn = cs+l+strspn(cs+l, whitespace);
|
||||||
|
|
||||||
|
char *filename;
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
if (strncmp(fn, PA_DEFAULT_CONFIG_DIR, strlen(PA_DEFAULT_CONFIG_DIR)) == 0)
|
||||||
|
filename = pa_sprintf_malloc("%s" PA_PATH_SEP "etc" PA_PATH_SEP "pulse" PA_PATH_SEP "%s",
|
||||||
|
pa_win32_get_toplevel(NULL),
|
||||||
|
fn + strlen(PA_DEFAULT_CONFIG_DIR));
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
filename = pa_xstrdup(fn);
|
||||||
|
|
||||||
if (stat(filename, &st) < 0) {
|
if (stat(filename, &st) < 0) {
|
||||||
pa_log_warn("stat('%s'): %s", filename, pa_cstrerror(errno));
|
pa_log_warn("stat('%s'): %s", filename, pa_cstrerror(errno));
|
||||||
if (*fail)
|
if (*fail) {
|
||||||
|
pa_xfree(filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
DIR *d;
|
DIR *d;
|
||||||
|
|
||||||
if (!(d = opendir(filename))) {
|
if (!(d = opendir(filename))) {
|
||||||
pa_log_warn("Failed to read '%s': %s", filename, pa_cstrerror(errno));
|
pa_log_warn("Failed to read '%s': %s", filename, pa_cstrerror(errno));
|
||||||
if (*fail)
|
if (*fail) {
|
||||||
|
pa_xfree(filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned i, count;
|
unsigned i, count;
|
||||||
char **sorted_files;
|
char **sorted_files;
|
||||||
|
|
@ -2143,14 +2157,18 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
|
||||||
pa_xfree(sorted_files[i]);
|
pa_xfree(sorted_files[i]);
|
||||||
}
|
}
|
||||||
pa_xfree(sorted_files);
|
pa_xfree(sorted_files);
|
||||||
if (failed)
|
if (failed) {
|
||||||
|
pa_xfree(filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pa_cli_command_execute_file(c, filename, buf, fail) < 0 && *fail) {
|
} else if (pa_cli_command_execute_file(c, filename, buf, fail) < 0 && *fail) {
|
||||||
|
pa_xfree(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pa_xfree(filename);
|
||||||
} else if (l == sizeof(META_IFEXISTS)-1 && !strncmp(cs, META_IFEXISTS, l)) {
|
} else if (l == sizeof(META_IFEXISTS)-1 && !strncmp(cs, META_IFEXISTS, l)) {
|
||||||
if (!ifstate) {
|
if (!ifstate) {
|
||||||
pa_strbuf_printf(buf, "Meta command %s is not valid in this context\n", cs);
|
pa_strbuf_printf(buf, "Meta command %s is not valid in this context\n", cs);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue