diff options
author | Denis Krjuchkov <denis@crazydev.net> | 2013-12-03 13:46:05 +0600 |
---|---|---|
committer | Denis Krjuchkov <denis@crazydev.net> | 2013-12-03 13:46:05 +0600 |
commit | 96413b16046f2edbb53ab7abcca73809f6cb3a54 (patch) | |
tree | 46c57b005ab97c28f1bb3a54cad8c7df11421797 /src/fs/Traits.cxx | |
parent | 2278fe42e55bbc713ccd2a45736a9eb9369afd36 (diff) | |
download | mpd-96413b16046f2edbb53ab7abcca73809f6cb3a54.tar.gz mpd-96413b16046f2edbb53ab7abcca73809f6cb3a54.tar.xz mpd-96413b16046f2edbb53ab7abcca73809f6cb3a54.zip |
fs/Traits.hxx: implement BuildFS() method
Diffstat (limited to 'src/fs/Traits.cxx')
-rw-r--r-- | src/fs/Traits.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index 2c3ce075b..aaf0a59e1 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -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) { |