path-win: implement cache directories

4502522a7a implemented cache directories
but only on linux which meant other OSes continued to save this stuff in
their config directory. Since we turned on cache by default, people are
getting cache files in there which is understandably causing some
confusion. Let's go ahead and implement a separate cache directory for
windows since there seems to be some established conventions for this
already. For people using the portable_path, the cache is saved in a
subdirectory within the portable_path since the idea is for that to be
completely self contained.
This commit is contained in:
Dudemanguy 2023-07-12 09:05:46 -05:00
parent 93f95f61e9
commit d482bf6ef0
1 changed files with 9 additions and 0 deletions

View File

@ -71,6 +71,11 @@ static char *mp_get_win_app_dir(void *talloc_ctx)
return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL; return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL;
} }
static char *mp_get_win_local_app_dir(void *talloc_ctx)
{
char *path = mp_get_win_shell_dir(talloc_ctx, &FOLDERID_LocalAppData);
return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL;
}
static void path_init(void) static void path_init(void)
{ {
@ -87,9 +92,13 @@ const char *mp_get_platform_path_win(void *talloc_ctx, const char *type)
if (portable_path) { if (portable_path) {
if (strcmp(type, "home") == 0) if (strcmp(type, "home") == 0)
return portable_path; return portable_path;
if (strcmp(type, "cache") == 0)
return mp_path_join(talloc_ctx, portable_path, "cache");
} else { } else {
if (strcmp(type, "home") == 0) if (strcmp(type, "home") == 0)
return mp_get_win_app_dir(talloc_ctx); return mp_get_win_app_dir(talloc_ctx);
if (strcmp(type, "cache") == 0)
return mp_get_win_local_app_dir(talloc_ctx);
if (strcmp(type, "exe_dir") == 0) if (strcmp(type, "exe_dir") == 0)
return mp_get_win_exe_dir(talloc_ctx); return mp_get_win_exe_dir(talloc_ctx);
// Not really true, but serves as a way to return a lowest-priority dir. // Not really true, but serves as a way to return a lowest-priority dir.