diff options
author | Dudemanguy <random342@airmail.cc> | 2023-05-02 19:42:23 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-05-09 20:37:17 +0000 |
commit | 4502522a7aee093c923e79a65e4684ea2634af30 (patch) | |
tree | d7855be2c4cfb6a16edc784da0e6f3dad29ee667 /options/path.c | |
parent | 7c4c9bc86f55f4d1224814fbeafdee8f1c3c3108 (diff) | |
download | mpv-4502522a7aee093c923e79a65e4684ea2634af30.tar.bz2 mpv-4502522a7aee093c923e79a65e4684ea2634af30.tar.xz |
player: use XDG_CACHE_HOME by default
This adds cache as a possible path for mpv to internally pick
(~/.cache/mpv for non-darwin unix-like systems, the usual config
directory for everyone else). For gpu shader cache and icc cache,
controlling whether or not to write such files is done with the new
--gpu-shader-cache and --icc-cache options respectively. Additionally,
--cache-on-disk no longer requires explicitly setting the --cache-dir
option. The old options, --cache-dir, --gpu-shader-cache-dir, and
--icc-cache-dir simply set an override for the directory to save cache
files. If unset, then the cache is saved in XDG_CACHE_HOME.
Diffstat (limited to 'options/path.c')
-rw-r--r-- | options/path.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/options/path.c b/options/path.c index 4ea7269d01..e1aaa48907 100644 --- a/options/path.c +++ b/options/path.c @@ -74,7 +74,7 @@ static const char *mp_get_platform_path(void *talloc_ctx, { assert(talloc_ctx); - bool config_dir = strcmp(type, "state") != 0; + bool config_dir = strcmp(type, "cache") != 0 && strcmp(type, "state") != 0; if (global->configdir && config_dir) { for (int n = 0; n < MP_ARRAY_SIZE(config_dirs); n++) { if (strcmp(config_dirs[n], type) == 0) @@ -84,6 +84,8 @@ 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"; @@ -102,7 +104,10 @@ void mp_init_paths(struct mpv_global *global, struct MPOpts *opts) // 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); |