summaryrefslogtreecommitdiff
path: root/src/util/WStringCompare.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-09-06 19:29:25 +0200
committerMax Kellermann <max@musicpd.org>2018-09-06 19:52:43 +0200
commit728e4e9a385a89b0ea38c4a0a89dbd0c123f1df3 (patch)
tree65ce70b0cb5fa791dbfc0a1463d494ec23a584a5 /src/util/WStringCompare.cxx
parent2d6f9f9a9c985c9a2e1fc155fdaa3fe07a57440b (diff)
util/StringCompare: add StringEndsWithIgnoreCase(), StringStartsWithIgnoreCase()
Diffstat (limited to 'src/util/WStringCompare.cxx')
-rw-r--r--src/util/WStringCompare.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/WStringCompare.cxx b/src/util/WStringCompare.cxx
index 18e77b77b..b255f8e64 100644
--- a/src/util/WStringCompare.cxx
+++ b/src/util/WStringCompare.cxx
@@ -39,6 +39,18 @@ StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept
StringIsEqual(haystack + haystack_length - needle_length, needle);
}
+bool
+StringEndsWithIgnoreCase(const wchar_t *haystack,
+ const wchar_t *needle) noexcept
+{
+ const size_t haystack_length = StringLength(haystack);
+ const size_t needle_length = StringLength(needle);
+
+ return haystack_length >= needle_length &&
+ StringIsEqualIgnoreCase(haystack + haystack_length - needle_length,
+ needle);
+}
+
const wchar_t *
FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept
{