From e9125ef8e4fc42ba123aa71b5aed6f7e8d05f103 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 2 Mar 2015 21:43:04 +0100 Subject: PlaylistFile: use PathTraitsFS typedefs --- src/PlaylistFile.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/PlaylistFile.cxx') diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 804f7d951..e22cacfea 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -37,6 +37,7 @@ #include "fs/FileSystem.hxx" #include "fs/FileInfo.hxx" #include "fs/DirectoryReader.hxx" +#include "util/Macros.hxx" #include "util/StringUtil.hxx" #include "util/UriUtil.hxx" #include "util/Error.hxx" @@ -168,10 +169,10 @@ LoadPlaylistFileInfo(PlaylistInfo &info, const Path parent_path_fs, const Path name_fs) { - const char *name_fs_str = name_fs.c_str(); - size_t name_length = strlen(name_fs_str); + const auto *const name_fs_str = name_fs.c_str(); + const size_t name_length = name_fs.length(); - if (name_length < sizeof(PLAYLIST_FILE_SUFFIX) || + if (name_length < ARRAY_SIZE(PLAYLIST_FILE_SUFFIX) || memchr(name_fs_str, '\n', name_length) != nullptr) return false; @@ -183,8 +184,8 @@ LoadPlaylistFileInfo(PlaylistInfo &info, if (!GetFileInfo(path_fs, fi) || !fi.IsRegular()) return false; - std::string name(name_fs_str, - name_length + 1 - sizeof(PLAYLIST_FILE_SUFFIX)); + PathTraitsFS::string name(name_fs_str, + name_length + 1 - ARRAY_SIZE(PLAYLIST_FILE_SUFFIX)); std::string name_utf8 = PathToUTF8(name.c_str()); if (name_utf8.empty()) return false; -- cgit v1.2.3