diff options
author | Denis Krjuchkov <denis@crazydev.net> | 2013-12-05 04:09:07 +0600 |
---|---|---|
committer | Denis Krjuchkov <denis@crazydev.net> | 2013-12-05 04:09:07 +0600 |
commit | c38703125223b1de11c2cca7b21e5649110a5c51 (patch) | |
tree | 03b36b872a246856deb1bf8040c9f441ec9f17cb /src/fs/Traits.hxx | |
parent | 403bd77eff726eb30bfc8a5db84ef8a783f3e827 (diff) | |
download | mpd-c38703125223b1de11c2cca7b21e5649110a5c51.tar.gz mpd-c38703125223b1de11c2cca7b21e5649110a5c51.tar.xz mpd-c38703125223b1de11c2cca7b21e5649110a5c51.zip |
fs/Traits.hxx: add FindLastSeparator function to PathTraitsXXX
Diffstat (limited to 'src/fs/Traits.hxx')
-rw-r--r-- | src/fs/Traits.hxx | 19 |
1 files changed, 19 insertions, 0 deletions
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 @@ -56,6 +56,19 @@ struct PathTraitsFS { } 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); #ifdef WIN32 @@ -97,6 +110,12 @@ struct PathTraitsUTF8 { } 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); #ifdef WIN32 |