Commit 6f1a4a73 authored by Max Kellermann's avatar Max Kellermann

fs/Traits: add GetFilenameSuffix()

parent 945ed261
...@@ -88,6 +88,14 @@ struct PathTraitsFS { ...@@ -88,6 +88,14 @@ struct PathTraitsFS {
#endif #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 #ifdef _WIN32
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static constexpr bool IsDrive(const_pointer p) noexcept { static constexpr bool IsDrive(const_pointer p) noexcept {
...@@ -199,6 +207,14 @@ struct PathTraitsUTF8 { ...@@ -199,6 +207,14 @@ struct PathTraitsUTF8 {
return std::strrchr(p, SEPARATOR); 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 #ifdef _WIN32
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static constexpr bool IsDrive(const_pointer p) noexcept { static constexpr bool IsDrive(const_pointer p) noexcept {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment