summaryrefslogtreecommitdiffstats
path: root/player/configfiles.c
diff options
context:
space:
mode:
authorKenneth Zhou <knthzh@gmail.com>2014-06-18 19:55:40 -0400
committerwm4 <wm4@nowhere>2014-06-26 19:37:25 +0200
commitcb250d490c14872f03bb0320179e48d05fe2539d (patch)
treedd27e22fcbb6e306175d041eb2b2c714b7079645 /player/configfiles.c
parent8bb7d427e2180067f13f8dc5c5105029e9e00be7 (diff)
downloadmpv-cb250d490c14872f03bb0320179e48d05fe2539d.tar.bz2
mpv-cb250d490c14872f03bb0320179e48d05fe2539d.tar.xz
Basic xdg directory implementation
Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file() Closes #864, #109. Signed-off-by: wm4 <wm4@nowhere>
Diffstat (limited to 'player/configfiles.c')
-rw-r--r--player/configfiles.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/player/configfiles.c b/player/configfiles.c
index 2794ddaebf..a295d7d9f2 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -71,21 +71,22 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
// The #if is a stupid hack to avoid errors if libavfilter is not available.
#if HAVE_LIBAVFILTER && HAVE_ENCODING
conffile = mp_find_config_file(tmp, mpctx->global, "encoding-profiles.conf");
- if (conffile && mp_path_exists(conffile))
+ if (conffile)
m_config_parse_config_file(mpctx->mconfig, conffile, SECT_ENCODE, 0);
#endif
- conffile = mp_find_global_config_file(tmp, mpctx->global, "mpv.conf");
- if (conffile && m_config_parse_config_file(conf, conffile, section, 0) < 0) {
- r = false;
- goto done;
+ // Maintain compatibility with /config
+ for (char** cf = mp_find_all_config_files(tmp, mpctx->global, "config"); *cf; cf++) {
+ if (m_config_parse_config_file(conf, *cf, section, 0) < 0) {
+ r = false;
+ goto done;
+ }
}
- mp_mk_config_dir(mpctx->global, NULL);
- if (!(conffile = mp_find_user_config_file(tmp, mpctx->global, "config")))
- MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n");
- else if (m_config_parse_config_file(conf, conffile, section, 0) < 0) {
- r = false;
- goto done;
+ for (char** cf = mp_find_all_config_files(tmp, mpctx->global, "mpv.conf"); *cf; cf++) {
+ if (m_config_parse_config_file(conf, *cf, section, 0) < 0) {
+ r = false;
+ goto done;
+ }
}
if (encoding)
@@ -134,7 +135,7 @@ static void mp_load_per_file_config(struct MPContext *mpctx)
return;
}
- if ((confpath = mp_find_user_config_file(NULL, mpctx->global, name))) {
+ if ((confpath = mp_find_config_file(NULL, mpctx->global, name))) {
try_load_config(mpctx, confpath, FILE_LOCAL_FLAGS);
talloc_free(confpath);
@@ -200,9 +201,13 @@ static char *mp_get_playback_resume_config_filename(struct mpv_global *global,
for (int i = 0; i < 16; i++)
conf = talloc_asprintf_append(conf, "%02X", md5[i]);
- conf = talloc_asprintf(tmp, "%s/%s", MP_WATCH_LATER_CONF, conf);
+ res = talloc_asprintf(tmp, MP_WATCH_LATER_CONF "/%s", conf);
+ res = mp_find_config_file(NULL, global, res);
- res = mp_find_user_config_file(NULL, global, conf);
+ if (!res) {
+ res = mp_find_config_file(tmp, global, MP_WATCH_LATER_CONF);
+ res = talloc_asprintf(NULL, "%s/%s", res, conf);
+ }
exit:
talloc_free(tmp);