diff options
author | Max Kellermann <max@duempel.org> | 2013-10-14 22:26:23 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-14 22:26:23 +0200 |
commit | 47d655ea7f0ed9c26ceba4767ef6aa82e434d129 (patch) | |
tree | e27837fa66d1baffd5bdd35abd7e4987779b3513 /src/fs/Path.cxx | |
parent | 62271bf6ce52804a944bf33d45cdab9fac37f93c (diff) | |
download | mpd-47d655ea7f0ed9c26ceba4767ef6aa82e434d129.tar.gz mpd-47d655ea7f0ed9c26ceba4767ef6aa82e434d129.tar.xz mpd-47d655ea7f0ed9c26ceba4767ef6aa82e434d129.zip |
fs/Path: add separator constants/functions
Diffstat (limited to 'src/fs/Path.cxx')
-rw-r--r-- | src/fs/Path.cxx | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx index 1a1f133d0..8f31f45f7 100644 --- a/src/fs/Path.cxx +++ b/src/fs/Path.cxx @@ -194,15 +194,32 @@ Path::RelativeFS(const char *other_fs) const other_fs += l; if (*other_fs != 0) { - if (!G_IS_DIR_SEPARATOR(*other_fs)) + if (!IsSeparatorFS(*other_fs)) /* mismatch */ return nullptr; /* skip remaining path separators */ do { ++other_fs; - } while (G_IS_DIR_SEPARATOR(*other_fs)); + } while (IsSeparatorFS(*other_fs)); } return other_fs; } + +void +Path::ChopSeparators() +{ + size_t l = length(); + const char *p = data(); + + while (l >= 2 && IsSeparatorFS(p[l - 1])) { + --l; + +#if GCC_CHECK_VERSION(4,7) && !defined(__clang__) + value.pop_back(); +#else + value.erase(value.end() - 1, value.end()); +#endif + } +} |