Commit b6b8fb7d authored by Max Kellermann's avatar Max Kellermann

PlaylistFile: use TruncateFile()

As a side effect, "playlistclear" no longer creates a new playlist if the given one doesn't yet exist.
parent 2bca3cd2
......@@ -302,11 +302,15 @@ spl_clear(const char *utf8path)
const auto path_fs = spl_map_to_fs(utf8path);
assert(!path_fs.IsNull());
FILE *file = FOpen(path_fs, FOpenMode::WriteText);
if (file == nullptr)
ThrowPlaylistErrno();
fclose(file);
try {
TruncateFile(path_fs);
} catch (const std::system_error &e) {
if (IsFileNotFound(e))
throw PlaylistError(PlaylistResult::NO_SUCH_LIST,
"No such playlist");
else
throw;
}
idle_add(IDLE_STORED_PLAYLIST);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment