aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/Path.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/Path.cxx')
-rw-r--r--src/fs/Path.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx
index 09616c9f4..1a1f133d0 100644
--- a/src/fs/Path.cxx
+++ b/src/fs/Path.cxx
@@ -184,3 +184,25 @@ void Path::GlobalInit()
SetFSCharset("ISO-8859-1");
}
}
+
+const char *
+Path::RelativeFS(const char *other_fs) const
+{
+ const size_t l = length();
+ if (memcmp(data(), other_fs, l) != 0)
+ return nullptr;
+
+ other_fs += l;
+ if (*other_fs != 0) {
+ if (!G_IS_DIR_SEPARATOR(*other_fs))
+ /* mismatch */
+ return nullptr;
+
+ /* skip remaining path separators */
+ do {
+ ++other_fs;
+ } while (G_IS_DIR_SEPARATOR(*other_fs));
+ }
+
+ return other_fs;
+}