fs/Traits.hxx: implement BuildFS() method
This commit is contained in:
parent
2278fe42e5
commit
96413b1604
@ -22,6 +22,31 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
PathTraits::string
|
||||
PathTraits::BuildFS(PathTraits::const_pointer a, size_t a_size,
|
||||
PathTraits::const_pointer b, size_t b_size)
|
||||
{
|
||||
assert(a != nullptr);
|
||||
assert(b != nullptr);
|
||||
|
||||
if (a_size == 0)
|
||||
return string(b, b_size);
|
||||
if (b_size == 0)
|
||||
return string(a, a_size);
|
||||
|
||||
string result(a, a_size);
|
||||
|
||||
if (!IsSeparatorFS(a[a_size - 1]))
|
||||
result.push_back(SEPARATOR_FS);
|
||||
|
||||
if (IsSeparatorFS(b[0]))
|
||||
result.append(b + 1, b_size - 1);
|
||||
else
|
||||
result.append(b, b_size);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *
|
||||
PathTraits::GetBaseUTF8(const char *p)
|
||||
{
|
||||
|
@ -86,6 +86,16 @@ struct PathTraits {
|
||||
return strlen(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 BuildFS(const_pointer a, size_t a_size,
|
||||
const_pointer b, size_t b_size);
|
||||
|
||||
/**
|
||||
* Determine the "base" file name of the given UTF-8 path.
|
||||
* The return value points inside the given string.
|
||||
|
Loading…
Reference in New Issue
Block a user