diff --git a/common/global.h b/common/global.h index 09b59593b0..f95cf28a4d 100644 --- a/common/global.h +++ b/common/global.h @@ -10,8 +10,6 @@ struct mpv_global { struct mp_client_api *client_api; char *configdir; struct stats_base *stats; - bool no_cachedir; - bool no_statedir; }; #endif diff --git a/options/path.c b/options/path.c index e1aaa48907..c9a986fe81 100644 --- a/options/path.c +++ b/options/path.c @@ -84,16 +84,20 @@ static const char *mp_get_platform_path(void *talloc_ctx, // Return the native config path if the platform doesn't support the // type we are trying to fetch. - if (strcmp(type, "cache") == 0 && global->no_cachedir) - type = "home"; - if (strcmp(type, "state") == 0 && global->no_statedir) - type = "home"; + const char *fallback_type = NULL; + if (!strcmp(type, "cache") || !strcmp(type, "state")) + fallback_type = "home"; for (int n = 0; n < MP_ARRAY_SIZE(path_resolvers); n++) { const char *path = path_resolvers[n](talloc_ctx, type); if (path && path[0]) return path; } + + if (fallback_type) { + assert(strcmp(fallback_type, type) != 0); + return mp_get_platform_path(talloc_ctx, global, fallback_type); + } return NULL; } @@ -101,17 +105,6 @@ void mp_init_paths(struct mpv_global *global, struct MPOpts *opts) { TA_FREEP(&global->configdir); - // Check if the platform has unique directories that differ from - // the standard config directory. - void *tmp = talloc_new(NULL); - const char *cache = mp_get_platform_path(tmp, global, "cache"); - const char *state = mp_get_platform_path(tmp, global, "state"); - if (!cache) - global->no_cachedir = true; - if (!state) - global->no_statedir = true; - talloc_free(tmp); - const char *force_configdir = getenv("MPV_HOME"); if (opts->force_configdir && opts->force_configdir[0]) force_configdir = opts->force_configdir;