summaryrefslogtreecommitdiffstats
path: root/options/path.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-06 22:40:55 +0100
committerwm4 <wm4@nowhere>2016-01-06 22:40:55 +0100
commit35f43dfacbe3abc000c1f35e36355613cb7da896 (patch)
treef21cae6345df3d6fa3a75b41444676a95b40ba2a /options/path.c
parentb7e179f6d3dc13d76bfdf4d5712e23328219c603 (diff)
downloadmpv-35f43dfacbe3abc000c1f35e36355613cb7da896.tar.bz2
mpv-35f43dfacbe3abc000c1f35e36355613cb7da896.tar.xz
player: make watch later/resume work when "playing" directories
If you do "mpv /bla/", and then branch out into sub-directories using playlist navigation, and then used quit and watch later, then playing the same directory did not resume from the previous point. This was because resuming is based on the path hash, so a path prefix can't be detected when resuming the parent directory. Solve this by writing each path prefix when playing directories is involved. (This includes all parent paths, so interestingly, "mpv /" would also resume in the above example.) Something like this was requested multiple times, and I want it too.
Diffstat (limited to 'options/path.c')
-rw-r--r--options/path.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/options/path.c b/options/path.c
index 5072e7312c..adfd2ded3e 100644
--- a/options/path.c
+++ b/options/path.c
@@ -213,6 +213,21 @@ struct bstr mp_dirname(const char *path)
return ret;
}
+
+#if HAVE_DOS_PATHS
+static const char mp_path_separators[] = "\\/";
+#else
+static const char mp_path_separators[] = "/";
+#endif
+
+// Mutates path and removes a trailing '/' (or '\' on Windows)
+void mp_path_strip_trailing_separator(char *path)
+{
+ size_t len = strlen(path);
+ if (len > 0 && strchr(mp_path_separators, path[len - 1]))
+ path[len - 1] = '\0';
+}
+
char *mp_splitext(const char *path, bstr *root)
{
assert(path);