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 /osdep/path-unix.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 'osdep/path-unix.c')
-rw-r--r-- | osdep/path-unix.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/osdep/path-unix.c b/osdep/path-unix.c index 34187b430e..5dc5cb2836 100644 --- a/osdep/path-unix.c +++ b/osdep/path-unix.c @@ -27,11 +27,13 @@ static pthread_once_t path_init_once = PTHREAD_ONCE_INIT; static char mpv_home[512]; static char old_home[512]; +static char mpv_cache[512]; static char mpv_state[512]; static void path_init(void) { char *home = getenv("HOME"); + char *xdg_cache = getenv("XDG_CACHE_HOME"); char *xdg_config = getenv("XDG_CONFIG_HOME"); char *xdg_state = getenv("XDG_STATE_HOME"); @@ -45,6 +47,12 @@ static void path_init(void) if (home && home[0]) snprintf(old_home, sizeof(old_home), "%s/.mpv", home); + if (xdg_cache && xdg_cache[0]) { + snprintf(mpv_cache, sizeof(mpv_cache), "%s/mpv", xdg_cache); + } else if (home && home[0]) { + snprintf(mpv_cache, sizeof(mpv_cache), "%s/.cache/mpv", home); + } + if (xdg_state && xdg_state[0]) { snprintf(mpv_state, sizeof(mpv_state), "%s/mpv", xdg_state); } else if (home && home[0]) { @@ -55,6 +63,7 @@ static void path_init(void) // config dir only. Also do not use any other XDG directories. if (mp_path_exists(old_home) && !mp_path_exists(mpv_home)) { snprintf(mpv_home, sizeof(mpv_home), "%s", old_home); + snprintf(mpv_cache, sizeof(mpv_cache), "%s", old_home); snprintf(mpv_state, sizeof(mpv_state), "%s", old_home); old_home[0] = '\0'; } @@ -67,6 +76,8 @@ const char *mp_get_platform_path_unix(void *talloc_ctx, const char *type) return mpv_home; if (strcmp(type, "old_home") == 0) return old_home; + if (strcmp(type, "cache") == 0) + return mpv_cache; if (strcmp(type, "state") == 0) return mpv_state; if (strcmp(type, "global") == 0) |