aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/Path.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-14 22:26:23 +0200
committerMax Kellermann <max@duempel.org>2013-10-14 22:26:23 +0200
commit47d655ea7f0ed9c26ceba4767ef6aa82e434d129 (patch)
treee27837fa66d1baffd5bdd35abd7e4987779b3513 /src/fs/Path.hxx
parent62271bf6ce52804a944bf33d45cdab9fac37f93c (diff)
downloadmpd-47d655ea7f0ed9c26ceba4767ef6aa82e434d129.tar.gz
mpd-47d655ea7f0ed9c26ceba4767ef6aa82e434d129.tar.xz
mpd-47d655ea7f0ed9c26ceba4767ef6aa82e434d129.zip
fs/Path: add separator constants/functions
Diffstat (limited to 'src/fs/Path.hxx')
-rw-r--r--src/fs/Path.hxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx
index 52a62ae76..bd3f3a94e 100644
--- a/src/fs/Path.hxx
+++ b/src/fs/Path.hxx
@@ -57,6 +57,14 @@ public:
typedef string::pointer pointer;
typedef string::const_pointer const_pointer;
+#ifdef WIN32
+ static constexpr value_type SEPARATOR_FS = '\\';
+ static constexpr char SEPARATOR_UTF8 = '/';
+#else
+ static constexpr value_type SEPARATOR_FS = '/';
+ static constexpr char SEPARATOR_UTF8 = '/';
+#endif
+
private:
string value;
@@ -232,6 +240,27 @@ public:
*/
gcc_pure
const char *RelativeFS(const char *other_fs) const;
+
+ /**
+ * Chop trailing directory separators.
+ */
+ void ChopSeparators();
+
+ static constexpr bool IsSeparatorFS(value_type ch) {
+ return
+#ifdef WIN32
+ ch == '/' ||
+#endif
+ ch == SEPARATOR_FS;
+ }
+
+ static constexpr bool IsSeparatorUTF8(char ch) {
+ return
+#ifdef WIN32
+ ch == '/' ||
+#endif
+ ch == SEPARATOR_UTF8;
+ }
};
#endif