From 0922678fc40fd13e70c32c1543f922962a35bbb7 Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Thu, 6 Jul 2017 15:26:24 +0100 Subject: 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. --- options/path.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'options/path.c') 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]; -- cgit v1.2.3