aboutsummaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/storage/StorageInterface.hxx8
-rw-r--r--src/storage/plugins/LocalStorage.cxx8
-rw-r--r--src/storage/plugins/SmbclientStorage.cxx8
3 files changed, 24 insertions, 0 deletions
diff --git a/src/storage/StorageInterface.hxx b/src/storage/StorageInterface.hxx
index 18bee8cfd..892e8e43b 100644
--- a/src/storage/StorageInterface.hxx
+++ b/src/storage/StorageInterface.hxx
@@ -68,6 +68,14 @@ public:
gcc_pure
AllocatedPath MapChildFS(const char *uri_utf8,
const char *child_utf8) const;
+
+ /**
+ * Check if the given URI points inside this storage. If yes,
+ * then it returns a relative URI (pointing inside the given
+ * string); if not, returns nullptr.
+ */
+ gcc_pure
+ virtual const char *MapToRelativeUTF8(const char *uri_utf8) const = 0;
};
#endif
diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx
index 23e87c1b5..5020a8fd6 100644
--- a/src/storage/plugins/LocalStorage.cxx
+++ b/src/storage/plugins/LocalStorage.cxx
@@ -68,6 +68,8 @@ public:
virtual AllocatedPath MapFS(const char *uri_utf8) const override;
+ virtual const char *MapToRelativeUTF8(const char *uri_utf8) const override;
+
private:
AllocatedPath MapFS(const char *uri_utf8, Error &error) const;
};
@@ -130,6 +132,12 @@ LocalStorage::MapFS(const char *uri_utf8) const
return MapFS(uri_utf8, IgnoreError());
}
+const char *
+LocalStorage::MapToRelativeUTF8(const char *uri_utf8) const
+{
+ return PathTraitsUTF8::Relative(base_utf8.c_str(), uri_utf8);
+}
+
bool
LocalStorage::GetInfo(const char *uri_utf8, bool follow, FileInfo &info,
Error &error)
diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx
index 8dafff082..6d61ab75e 100644
--- a/src/storage/plugins/SmbclientStorage.cxx
+++ b/src/storage/plugins/SmbclientStorage.cxx
@@ -69,6 +69,8 @@ public:
Error &error) override;
virtual std::string MapUTF8(const char *uri_utf8) const override;
+
+ virtual const char *MapToRelativeUTF8(const char *uri_utf8) const override;
};
std::string
@@ -82,6 +84,12 @@ SmbclientStorage::MapUTF8(const char *uri_utf8) const
return PathTraitsUTF8::Build(base.c_str(), uri_utf8);
}
+const char *
+SmbclientStorage::MapToRelativeUTF8(const char *uri_utf8) const
+{
+ return PathTraitsUTF8::Relative(base.c_str(), uri_utf8);
+}
+
static bool
GetInfo(const char *path, FileInfo &info, Error &error)
{