From c38703125223b1de11c2cca7b21e5649110a5c51 Mon Sep 17 00:00:00 2001 From: Denis Krjuchkov Date: Thu, 5 Dec 2013 04:09:07 +0600 Subject: fs/Traits.hxx: add FindLastSeparator function to PathTraitsXXX --- src/fs/Traits.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 6ec5ebd2b..5ba82549e 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -55,6 +55,19 @@ struct PathTraitsFS { ch == SEPARATOR; } + gcc_pure gcc_nonnull_all + static const_pointer FindLastSeparator(const_pointer p) { + assert(p != nullptr); +#ifdef WIN32 + const_pointer pos = p + GetLength(p); + while (p != pos && !IsSeparator(*pos)) + --pos; + return IsSeparator(*pos) ? pos : nullptr; +#else + return strrchr(p, SEPARATOR); +#endif + } + gcc_pure gcc_nonnull_all static bool IsAbsolute(const_pointer p) { assert(p != nullptr); @@ -96,6 +109,12 @@ struct PathTraitsUTF8 { return ch == SEPARATOR; } + gcc_pure gcc_nonnull_all + static const_pointer FindLastSeparator(const_pointer p) { + assert(p != nullptr); + return strrchr(p, SEPARATOR); + } + gcc_pure gcc_nonnull_all static bool IsAbsolute(const_pointer p) { assert(p != nullptr); -- cgit v1.2.3