fs/Traits: implement GetBase/GetParent/Build using templates

This commit is contained in:
Denis Krjuchkov
2013-12-05 04:47:07 +06:00
parent 83e6e3e31f
commit 289fdcc52b
2 changed files with 88 additions and 22 deletions

View File

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