From 9508ea982b8feb012a9d354a7c80005421a854bc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 14 Oct 2013 22:38:29 +0200 Subject: fs/Path: add method IsAbsolute() --- src/fs/Path.hxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/fs') 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 +#endif + #include #include @@ -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 -- cgit v1.2.3