From da50c888fe708b67f287bc211854c3e83f54ce9a Mon Sep 17 00:00:00 2001 From: Denis Krjuchkov Date: Thu, 5 Dec 2013 13:20:55 +0600 Subject: fs/Traits.hxx: introduce PathTraitsXXX::IsDrive function --- src/fs/Traits.hxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/fs') diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index ff7978b6b..927496e53 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -68,11 +68,18 @@ struct PathTraitsFS { #endif } +#ifdef WIN32 + gcc_pure gcc_nonnull_all + static constexpr bool IsDrive(const_pointer p) { + return IsAlphaASCII(p[0]) && p[1] == ':'; + } +#endif + gcc_pure gcc_nonnull_all static bool IsAbsolute(const_pointer p) { assert(p != nullptr); #ifdef WIN32 - if (IsAlphaASCII(p[0]) && p[1] == ':' && IsSeparator(p[2])) + if (IsDrive(p) && IsSeparator(p[2])) return true; #endif return IsSeparator(*p); @@ -135,11 +142,18 @@ struct PathTraitsUTF8 { return strrchr(p, SEPARATOR); } +#ifdef WIN32 + gcc_pure gcc_nonnull_all + static constexpr bool IsDrive(const_pointer p) { + return IsAlphaASCII(p[0]) && p[1] == ':'; + } +#endif + gcc_pure gcc_nonnull_all static bool IsAbsolute(const_pointer p) { assert(p != nullptr); #ifdef WIN32 - if (IsAlphaASCII(p[0]) && p[1] == ':' && IsSeparator(p[2])) + if (IsDrive(p) && IsSeparator(p[2])) return true; #endif return IsSeparator(*p); -- cgit v1.2.3