fs/Path: add method IsAbsolute()

This commit is contained in:
Max Kellermann
2013-10-14 22:38:29 +02:00
parent 47d655ea7f
commit 9508ea982b
12 changed files with 47 additions and 12 deletions

View File

@@ -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