mirror of https://github.com/mpv-player/mpv
player: undeprecate 'config' files
Actually, it's pretty simple to look for multiple filenames at once,
since mp_find_all_config_files() is already a bit "special" anyway.
See #1569. Reverts most of commit db167cd4
(keeps osx-bundle.conf).
This commit is contained in:
parent
cf073138b2
commit
a27aa68dd3
|
@ -147,12 +147,15 @@ char **mp_find_all_config_files(void *talloc_ctx, struct mpv_global *global,
|
||||||
|
|
||||||
char **dirs = mp_config_dirs(NULL, global);
|
char **dirs = mp_config_dirs(NULL, global);
|
||||||
for (int i = 0; dirs && dirs[i]; i++) {
|
for (int i = 0; dirs && dirs[i]; i++) {
|
||||||
char *file = talloc_asprintf(ret, "%s/%s", dirs[i], filename);
|
bstr s = bstr0(filename);
|
||||||
|
while (s.len) {
|
||||||
|
bstr fn;
|
||||||
|
bstr_split_tok(s, "|", &fn, &s);
|
||||||
|
|
||||||
if (!mp_path_exists(file) || num_ret >= MAX_CONFIG_PATHS)
|
char *file = talloc_asprintf(ret, "%s/%.*s", dirs[i], BSTR_P(fn));
|
||||||
continue;
|
if (mp_path_exists(file) && num_ret < MAX_CONFIG_PATHS)
|
||||||
|
ret[num_ret++] = file;
|
||||||
ret[num_ret++] = file;
|
}
|
||||||
}
|
}
|
||||||
talloc_free(dirs);
|
talloc_free(dirs);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
// Find all instances of the given config file. Paths are returned in order
|
// Find all instances of the given config file. Paths are returned in order
|
||||||
// from lowest to highest priority.
|
// from lowest to highest priority. filename can contain multiple names
|
||||||
|
// separated with '|', with the first having highest priority.
|
||||||
char **mp_find_all_config_files(void *talloc_ctx, struct mpv_global *global,
|
char **mp_find_all_config_files(void *talloc_ctx, struct mpv_global *global,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
|
|
|
@ -46,29 +46,13 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
static int load_all_cfgfiles(struct MPContext *mpctx, char *section,
|
static void load_all_cfgfiles(struct MPContext *mpctx, char *section,
|
||||||
char *filename, bool bork)
|
char *filename)
|
||||||
{
|
{
|
||||||
char **cf = mp_find_all_config_files(NULL, mpctx->global, filename);
|
char **cf = mp_find_all_config_files(NULL, mpctx->global, filename);
|
||||||
int count = 0;
|
for (int i = 0; cf && cf[i]; i++)
|
||||||
for (int i = 0; cf && cf[i]; i++) {
|
|
||||||
if (strcmp(filename, "config") == 0) {
|
|
||||||
MP_WARN(mpctx, "Loading %s - naming the mpv config files 'config' is "
|
|
||||||
"deprecated. Please rename it to 'mpv.conf'\n", cf[i]);
|
|
||||||
}
|
|
||||||
if (bork) {
|
|
||||||
MP_WARN(mpctx, "Warning: your system has a 'mpv.conf' somewhere "
|
|
||||||
"(check with -v), which will shadow 'config'. This "
|
|
||||||
"is probably unintended, and you should not mix "
|
|
||||||
"'config' and 'mpv.conf' files.\n"
|
|
||||||
"Just rename this file to mpv.conf.\n");
|
|
||||||
bork = false;
|
|
||||||
}
|
|
||||||
m_config_parse_config_file(mpctx->mconfig, cf[i], section, 0);
|
m_config_parse_config_file(mpctx->mconfig, cf[i], section, 0);
|
||||||
count++;
|
|
||||||
}
|
|
||||||
talloc_free(cf);
|
talloc_free(cf);
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SECT_ENCODE "encoding"
|
#define SECT_ENCODE "encoding"
|
||||||
|
@ -103,11 +87,10 @@ void mp_parse_cfgfiles(struct MPContext *mpctx)
|
||||||
// Stupid hack to set OSX bundle defaults, if applicable. (The file is only
|
// Stupid hack to set OSX bundle defaults, if applicable. (The file is only
|
||||||
// found if starting from the OSX bundle.)
|
// found if starting from the OSX bundle.)
|
||||||
#if HAVE_COCOA
|
#if HAVE_COCOA
|
||||||
load_all_cfgfiles(mpctx, section, "osx-bundle.conf", false);
|
load_all_cfgfiles(mpctx, section, "osx-bundle.conf");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int count = load_all_cfgfiles(mpctx, section, "mpv.conf", false);
|
load_all_cfgfiles(mpctx, section, "mpv.conf|config");
|
||||||
load_all_cfgfiles(mpctx, section, "config", count > 0);
|
|
||||||
|
|
||||||
if (encoding)
|
if (encoding)
|
||||||
m_config_set_profile(conf, m_config_add_profile(conf, SECT_ENCODE), 0);
|
m_config_set_profile(conf, m_config_add_profile(conf, SECT_ENCODE), 0);
|
||||||
|
|
Loading…
Reference in New Issue