1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-18 13:14:36 +00:00

options/path: fallback to USERPROFILE if HOME isn't set

HOME isn't set by default on Windows. But if the user does set it,
prefer it by default.

Enables stuff like --log-file=~/mpv.log to work, even if HOME isn't set.
This commit is contained in:
Ricardo Constantino 2017-07-06 15:26:24 +01:00
parent 01d8aad1e8
commit 0922678fc4
No known key found for this signature in database
GPG Key ID: EFD16019AE4FF531

View File

@ -173,7 +173,10 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
talloc_free(tmp); talloc_free(tmp);
} }
} else if (bstr_equals0(prefix, "")) { } else if (bstr_equals0(prefix, "")) {
res = mp_path_join_bstr(talloc_ctx, bstr0(getenv("HOME")), rest); char *home = getenv("HOME");
if (!home)
home = getenv("USERPROFILE");
res = mp_path_join_bstr(talloc_ctx, bstr0(home), rest);
} else if (bstr_eatstart0(&prefix, "~")) { } else if (bstr_eatstart0(&prefix, "~")) {
void *tmp = talloc_new(NULL); void *tmp = talloc_new(NULL);
char type[80]; char type[80];