PlaylistFile: move memchr() call to class Path
This commit is contained in:
parent
e9125ef8e4
commit
87a8a3e22f
|
@ -169,11 +169,13 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
|
||||||
const Path parent_path_fs,
|
const Path parent_path_fs,
|
||||||
const Path name_fs)
|
const Path name_fs)
|
||||||
{
|
{
|
||||||
|
if (name_fs.HasNewline())
|
||||||
|
return false;
|
||||||
|
|
||||||
const auto *const name_fs_str = name_fs.c_str();
|
const auto *const name_fs_str = name_fs.c_str();
|
||||||
const size_t name_length = name_fs.length();
|
const size_t name_length = name_fs.length();
|
||||||
|
|
||||||
if (name_length < ARRAY_SIZE(PLAYLIST_FILE_SUFFIX) ||
|
if (name_length < ARRAY_SIZE(PLAYLIST_FILE_SUFFIX))
|
||||||
memchr(name_fs_str, '\n', name_length) != nullptr)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!StringEndsWith(name_fs_str, PLAYLIST_FILE_SUFFIX))
|
if (!StringEndsWith(name_fs_str, PLAYLIST_FILE_SUFFIX))
|
||||||
|
|
|
@ -122,6 +122,16 @@ public:
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the path contain a newline character? (Which is
|
||||||
|
* usually rejected by MPD because its protocol cannot
|
||||||
|
* transfer newline characters).
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
bool HasNewline() const {
|
||||||
|
return strchr(value, '\n') != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the path to UTF-8.
|
* Convert the path to UTF-8.
|
||||||
* Returns empty string on error or if this instance is "nulled"
|
* Returns empty string on error or if this instance is "nulled"
|
||||||
|
|
Loading…
Reference in New Issue