summaryrefslogtreecommitdiffstats
path: root/options/path.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-29 16:44:01 +0200
committerwm4 <wm4@nowhere>2016-09-29 16:44:01 +0200
commit86ab4b8a9fbcbb337add2bf06985c5de2aea7a90 (patch)
treec18516ad6eaa217424e98d39f6bfc10565858c0c /options/path.c
parentb81ae52f508fa1e4447e97223f79f4c59ff99197 (diff)
downloadmpv-86ab4b8a9fbcbb337add2bf06985c5de2aea7a90.tar.bz2
mpv-86ab4b8a9fbcbb337add2bf06985c5de2aea7a90.tar.xz
path: default ~~ paths to home directory
The code for expanding the ~~ prefix used mp_find_config_file(), which strictly looks for _existing_ files in any config path (e.g. not just the user-local one, but also system-wide config). If no such file exists, it simply returns NULL, which makes the code below just return the literal, unexpanded path. Change this so that it'll resolve the path to the user-local config directory instead. Requested in #3591.
Diffstat (limited to 'options/path.c')
-rw-r--r--options/path.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/options/path.c b/options/path.c
index cd1deb6e78..7353d6fffd 100644
--- a/options/path.c
+++ b/options/path.c
@@ -169,6 +169,12 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
const char *rest0 = rest.start; // ok in this case
if (bstr_equals0(prefix, "~")) {
res = mp_find_config_file(talloc_ctx, global, rest0);
+ if (!res) {
+ void *tmp = talloc_new(NULL);
+ const char *p = mp_get_platform_path(tmp, global, "home");
+ res = mp_path_join_bstr(talloc_ctx, bstr0(p), rest);
+ talloc_free(tmp);
+ }
} else if (bstr_equals0(prefix, "")) {
res = mp_path_join_bstr(talloc_ctx, bstr0(getenv("HOME")), rest);
} else if (bstr_eatstart0(&prefix, "~")) {