From 289fdcc52b34e3ac4ff08355c47cb0e8bac6f737 Mon Sep 17 00:00:00 2001 From: Denis Krjuchkov Date: Thu, 5 Dec 2013 04:47:07 +0600 Subject: fs/Traits: implement GetBase/GetParent/Build using templates --- src/fs/Traits.hxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/fs/Traits.hxx') diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 5ba82549e..bd65f53bf 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -83,6 +83,21 @@ struct PathTraitsFS { return strlen(p); } + /** + * Determine the "base" file name of the given native path. + * The return value points inside the given string. + */ + gcc_pure gcc_nonnull_all + static const_pointer GetBase(const_pointer p); + + /** + * Determine the "parent" file name of the given native path. + * As a special case, returns the string "." if there is no + * separator in the given input string. + */ + gcc_pure gcc_nonnull_all + static string GetParent(const_pointer p); + /** * Constructs the path from the given components. * If either of the components is empty string, @@ -139,6 +154,16 @@ struct PathTraitsUTF8 { */ gcc_pure gcc_nonnull_all static string GetParent(const_pointer p); + + /** + * Constructs the path from the given components. + * If either of the components is empty string, + * remaining component is returned unchanged. + * If both components are empty strings, empty string is returned. + */ + gcc_pure gcc_nonnull_all + static string Build(const_pointer a, size_t a_size, + const_pointer b, size_t b_size); }; #endif -- cgit v1.2.3