diff options
author | Max Kellermann <max@duempel.org> | 2015-03-02 22:26:46 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-03-03 11:29:31 +0100 |
commit | 820debf45a3bc5567fc16a4f982bdf41df7d7ef2 (patch) | |
tree | c5a83325ebabf0079609c8976c89f59a08909685 /src/PlaylistFile.cxx | |
parent | c19292c036ecc8791ad985968638baa76b7f0d3c (diff) | |
download | mpd-820debf45a3bc5567fc16a4f982bdf41df7d7ef2.tar.gz mpd-820debf45a3bc5567fc16a4f982bdf41df7d7ef2.tar.xz mpd-820debf45a3bc5567fc16a4f982bdf41df7d7ef2.zip |
util/StringUtil: add FindStringSuffix()
Diffstat (limited to 'src/PlaylistFile.cxx')
-rw-r--r-- | src/PlaylistFile.cxx | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index f9c3ab3f3..43dcca294 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -173,12 +173,9 @@ LoadPlaylistFileInfo(PlaylistInfo &info, return false; const auto *const name_fs_str = name_fs.c_str(); - const size_t name_length = name_fs.length(); - - if (name_length < ARRAY_SIZE(PLAYLIST_FILE_SUFFIX)) - return false; - - if (!StringEndsWith(name_fs_str, PLAYLIST_FILE_SUFFIX)) + const auto *const name_fs_end = + FindStringSuffix(name_fs_str, PLAYLIST_FILE_SUFFIX); + if (name_fs_end == nullptr) return false; FileInfo fi; @@ -186,8 +183,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info, !fi.IsRegular()) return false; - PathTraitsFS::string name(name_fs_str, - name_length + 1 - ARRAY_SIZE(PLAYLIST_FILE_SUFFIX)); + PathTraitsFS::string name(name_fs_str, name_fs_end); std::string name_utf8 = PathToUTF8(name.c_str()); if (name_utf8.empty()) return false; |