diff options
author | Ricardo Constantino <wiiaboo@gmail.com> | 2017-07-06 15:26:24 +0100 |
---|---|---|
committer | Ricardo Constantino <wiiaboo@gmail.com> | 2017-07-06 15:45:08 +0100 |
commit | 0922678fc40fd13e70c32c1543f922962a35bbb7 (patch) | |
tree | bc6335fa61a5d2e121c11b9779cd373cc091a350 /options | |
parent | 01d8aad1e847732808f2b70085b664088ab1c517 (diff) | |
download | mpv-0922678fc40fd13e70c32c1543f922962a35bbb7.tar.bz2 mpv-0922678fc40fd13e70c32c1543f922962a35bbb7.tar.xz |
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.
Diffstat (limited to 'options')
-rw-r--r-- | options/path.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/options/path.c b/options/path.c index cd14e66bb7..5248a1d75b 100644 --- a/options/path.c +++ b/options/path.c @@ -173,7 +173,10 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global, talloc_free(tmp); } } 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, "~")) { void *tmp = talloc_new(NULL); char type[80]; |