aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/Path.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-03-05 08:45:04 +0100
committerMax Kellermann <max@duempel.org>2015-03-05 10:07:07 +0100
commit2f41eba100f85f340ec9ca6b31f82dd3f22a01ff (patch)
tree8d71436af79df2435e58a7d70398476327e5f66d /src/fs/Path.cxx
parent91a6fb81c1d0648687c8602be90650d5330c2128 (diff)
downloadmpd-2f41eba100f85f340ec9ca6b31f82dd3f22a01ff.tar.gz
mpd-2f41eba100f85f340ec9ca6b31f82dd3f22a01ff.tar.xz
mpd-2f41eba100f85f340ec9ca6b31f82dd3f22a01ff.zip
fs/Path: reimplement GetSuffix() using GetBase() and StringFindLast()
Diffstat (limited to 'src/fs/Path.cxx')
-rw-r--r--src/fs/Path.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx
index 466d952b3..99a4ffb61 100644
--- a/src/fs/Path.cxx
+++ b/src/fs/Path.cxx
@@ -21,6 +21,7 @@
#include "Path.hxx"
#include "Charset.hxx"
#include "util/UriUtil.hxx"
+#include "util/StringUtil.hxx"
std::string
Path::ToUTF8() const
@@ -31,5 +32,10 @@ Path::ToUTF8() const
Path::const_pointer
Path::GetSuffix() const
{
- return uri_get_suffix(c_str());
+ const auto base = GetBase().c_str();
+ const auto *dot = StringFindLast(base, '.');
+ if (dot == nullptr || dot == base)
+ return nullptr;
+
+ return dot + 1;
}