summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-14 22:38:29 +0200
committerMax Kellermann <max@duempel.org>2013-10-14 22:38:29 +0200
commit9508ea982b8feb012a9d354a7c80005421a854bc (patch)
tree4c50648506d2ad1bcc5ebbf93138b62074310840 /src/fs
parent47d655ea7f0ed9c26ceba4767ef6aa82e434d129 (diff)
fs/Path: add method IsAbsolute()
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Path.hxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx
index bd3f3a94e..a5215c2d6 100644
--- a/src/fs/Path.hxx
+++ b/src/fs/Path.hxx
@@ -23,6 +23,10 @@
#include "check.h"
#include "gcc.h"
+#ifdef WIN32
+#include <glib.h>
+#endif
+
#include <algorithm>
#include <string>
@@ -261,6 +265,33 @@ public:
#endif
ch == SEPARATOR_UTF8;
}
+
+ gcc_pure
+ static bool IsAbsoluteFS(const_pointer p) {
+ assert(p != nullptr);
+
+#ifdef WIN32
+ return g_path_is_absolute(p);
+#else
+ return IsSeparatorFS(*p);
+#endif
+ }
+
+ gcc_pure
+ static bool IsAbsoluteUTF8(const char *p) {
+ assert(p != nullptr);
+
+#ifdef WIN32
+ return g_path_is_absolute(p);
+#else
+ return IsSeparatorUTF8(*p);
+#endif
+ }
+
+ gcc_pure
+ bool IsAbsolute() {
+ return IsAbsoluteFS(c_str());
+ }
};
#endif