fs/Traits.hxx: add FindLastSeparator function to PathTraitsXXX

This commit is contained in:
Denis Krjuchkov 2013-12-05 04:09:07 +06:00
parent 403bd77eff
commit c387031252

View File

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