fs/Traits: add GetFilenameSuffix() overload with std::string_view
This commit is contained in:
parent
449d59af2f
commit
20bbe1b57b
|
@ -92,6 +92,14 @@ struct PathTraitsFS {
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static string_view GetFilenameSuffix(string_view filename) noexcept {
|
||||
const auto dot = filename.rfind('.');
|
||||
return dot != filename.npos && dot > 0
|
||||
? filename.substr(dot + 1)
|
||||
: string_view{};
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static const_pointer GetPathSuffix(const_pointer path) noexcept {
|
||||
return GetFilenameSuffix(GetBase(path));
|
||||
|
@ -228,6 +236,14 @@ struct PathTraitsUTF8 {
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static string_view GetFilenameSuffix(string_view filename) noexcept {
|
||||
const auto dot = filename.rfind('.');
|
||||
return dot != filename.npos && dot > 0
|
||||
? filename.substr(dot + 1)
|
||||
: string_view{};
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static const_pointer GetPathSuffix(const_pointer path) noexcept {
|
||||
return GetFilenameSuffix(GetBase(path));
|
||||
|
|
Loading…
Reference in New Issue