diff options
author | Anton Kindestam <antonki@kth.se> | 2018-12-05 19:02:03 +0100 |
---|---|---|
committer | Anton Kindestam <antonki@kth.se> | 2018-12-05 19:19:24 +0100 |
commit | 8b83c8996686072bc743b112ae5cb3bf93aa33ed (patch) | |
tree | b09ce6a7ff470b05006622f19914b3d39d2f7d9f /options/path.c | |
parent | 5bcac8580df6fc62323136f756a3a6d1e754fe9c (diff) | |
parent | 559a400ac36e75a8d73ba263fd7fa6736df1c2da (diff) | |
download | mpv-8b83c8996686072bc743b112ae5cb3bf93aa33ed.tar.bz2 mpv-8b83c8996686072bc743b112ae5cb3bf93aa33ed.tar.xz |
Merge commit '559a400ac36e75a8d73ba263fd7fa6736df1c2da' into wm4-commits--merge-edition
This bumps libmpv version to 1.103
Diffstat (limited to 'options/path.c')
-rw-r--r-- | options/path.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/options/path.c b/options/path.c index dac9238cf9..d2b74516e1 100644 --- a/options/path.c +++ b/options/path.c @@ -61,6 +61,19 @@ static const char *const config_dirs[] = { "global", }; +void mp_init_paths(struct mpv_global *global, struct MPOpts *opts) +{ + TA_FREEP(&global->configdir); + + const char *force_configdir = getenv("MPV_HOME"); + if (opts->force_configdir && opts->force_configdir[0]) + force_configdir = opts->force_configdir; + if (!opts->load_config) + force_configdir = ""; + + global->configdir = talloc_strdup(global, force_configdir); +} + // Return a platform specific path using a path type as defined in osdep/path.h. // Keep in mind that the only way to free the return value is freeing talloc_ctx // (or its children), as this function can return a statically allocated string. @@ -70,15 +83,10 @@ static const char *mp_get_platform_path(void *talloc_ctx, { assert(talloc_ctx); - const char *force_configdir = getenv("MPV_HOME"); - if (global->opts->force_configdir && global->opts->force_configdir[0]) - force_configdir = global->opts->force_configdir; - if (!global->opts->load_config) - force_configdir = ""; - if (force_configdir) { + if (global->configdir) { for (int n = 0; n < MP_ARRAY_SIZE(config_dirs); n++) { if (strcmp(config_dirs[n], type) == 0) - return (n == 0 && force_configdir[0]) ? force_configdir : NULL; + return (n == 0 && global->configdir[0]) ? global->configdir : NULL; } } |