fs/Traits: add function Relative()

Move code from Path::RelativeFS() and make it generic.
This commit is contained in:
Max Kellermann
2014-02-07 18:58:37 +01:00
parent 6b421cc354
commit d744c997d8
4 changed files with 61 additions and 23 deletions

View File

@@ -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,