[core] Add str_endswith_ignore_case to avoid heap allocation in audio file type detection (#13313)
This commit is contained in:
1 parent
db0b32bfc9
commit
680e92a226
3 files changed
+19
-5
No files matched your search
@@ -174,6 +174,13 @@ bool str_endswith(const std::string &str, const std::string &end) {
|
||||
return str.rfind(end) == (str.size() - end.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
bool str_endswith_ignore_case(const char *str, size_t str_len, const char *suffix, size_t suffix_len) {
|
||||
if (suffix_len > str_len)
|
||||
return false;
|
||||
return strncasecmp(str + str_len - suffix_len, suffix, suffix_len) == 0;
|
||||
}
|
||||
|
||||
std::string str_truncate(const std::string &str, size_t length) {
|
||||
return str.length() > length ? str.substr(0, length) : str;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user