From d744c997d8a4370d56901c5bdf92d3cca0ef83bc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 7 Feb 2014 18:58:37 +0100 Subject: fs/Traits: add function Relative() Move code from Path::RelativeFS() and make it generic. --- src/fs/Traits.hxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/fs/Traits.hxx') diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 323656991..88715c3e8 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -105,6 +105,15 @@ struct PathTraitsFS { gcc_pure gcc_nonnull_all static string GetParent(const_pointer p); + /** + * Determine the relative part of the given path to this + * object, not including the directory separator. Returns an + * empty string if the given path equals this object or + * nullptr on mismatch. + */ + gcc_pure gcc_nonnull_all + static const_pointer Relative(const_pointer base, const_pointer other); + /** * Constructs the path from the given components. * If either of the components is empty string, @@ -179,6 +188,15 @@ struct PathTraitsUTF8 { gcc_pure gcc_nonnull_all static string GetParent(const_pointer p); + /** + * Determine the relative part of the given path to this + * object, not including the directory separator. Returns an + * empty string if the given path equals this object or + * nullptr on mismatch. + */ + gcc_pure gcc_nonnull_all + static const_pointer Relative(const_pointer base, const_pointer other); + /** * Constructs the path from the given components. * If either of the components is empty string, -- cgit v1.2.3