fs/Traits: add GetFilenameSuffix()

This commit is contained in:
Max Kellermann 2020-10-27 18:58:25 +01:00
parent 945ed2610a
commit 6f1a4a73b7

View File

@ -88,6 +88,14 @@ struct PathTraitsFS {
#endif
}
gcc_pure
static const_pointer GetFilenameSuffix(const_pointer filename) noexcept {
const_pointer dot = StringFindLast(filename, '.');
return dot != nullptr && dot > filename && dot[1] != 0
? dot + 1
: nullptr;
}
#ifdef _WIN32
gcc_pure gcc_nonnull_all
static constexpr bool IsDrive(const_pointer p) noexcept {
@ -199,6 +207,14 @@ struct PathTraitsUTF8 {
return std::strrchr(p, SEPARATOR);
}
gcc_pure
static const_pointer GetFilenameSuffix(const_pointer filename) noexcept {
const_pointer dot = StringFindLast(filename, '.');
return dot != nullptr && dot > filename && dot[1] != 0
? dot + 1
: nullptr;
}
#ifdef _WIN32
gcc_pure gcc_nonnull_all
static constexpr bool IsDrive(const_pointer p) noexcept {