summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-10-27 18:58:25 +0100
committerMax Kellermann <max@musicpd.org>2020-10-27 19:14:31 +0100
commit6f1a4a73b754810408cfbb449d0c71e63b762e82 (patch)
tree3502a4cd770feba9ccfe71ddb8dfb03d3e8818b0 /src/fs
parent945ed2610a0ae2b68288cf4f7b7a6cd4c1903bb5 (diff)
fs/Traits: add GetFilenameSuffix()
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Traits.hxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx
index da899df63..b61de1833 100644
--- a/src/fs/Traits.hxx
+++ b/src/fs/Traits.hxx
@@ -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 {