From ade847bc8999850b49730c036d30fa9f27bdb1cd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 25 Oct 2021 12:11:45 +0200 Subject: [PATCH] PlaylistFile: fold spl_move_index() into handle_playlistmove() --- src/PlaylistFile.cxx | 21 --------------------- src/PlaylistFile.hxx | 6 ------ src/command/PlaylistCommands.cxx | 13 +++++++++++-- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 38a9da87e..08c91c6ae 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -321,19 +321,6 @@ PlaylistFileEditor::Save() idle_add(IDLE_STORED_PLAYLIST); } -void -spl_move_index(const char *utf8path, unsigned src, unsigned dest) -{ - if (src == dest) - /* this doesn't check whether the playlist exists, but - what the hell.. */ - return; - - PlaylistFileEditor editor(utf8path, PlaylistFileEditor::LoadMode::YES); - editor.MoveIndex(src, dest); - editor.Save(); -} - void spl_clear(const char *utf8path) { @@ -372,14 +359,6 @@ spl_delete(const char *name_utf8) idle_add(IDLE_STORED_PLAYLIST); } -void -spl_remove_index(const char *utf8path, unsigned pos) -{ - PlaylistFileEditor editor(utf8path, PlaylistFileEditor::LoadMode::YES); - editor.RemoveIndex(pos); - editor.Save(); -} - void spl_append_song(const char *utf8path, const DetachedSong &song) try { diff --git a/src/PlaylistFile.hxx b/src/PlaylistFile.hxx index a22d274a4..063a482d4 100644 --- a/src/PlaylistFile.hxx +++ b/src/PlaylistFile.hxx @@ -89,18 +89,12 @@ spl_map_to_fs(const char *name_utf8); PlaylistVector ListPlaylistFiles(); -void -spl_move_index(const char *utf8path, unsigned src, unsigned dest); - void spl_clear(const char *utf8path); void spl_delete(const char *name_utf8); -void -spl_remove_index(const char *utf8path, unsigned pos); - void spl_append_song(const char *utf8path, const DetachedSong &song); diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx index d3398fc22..1654aeddc 100644 --- a/src/command/PlaylistCommands.cxx +++ b/src/command/PlaylistCommands.cxx @@ -177,7 +177,9 @@ handle_playlistdelete([[maybe_unused]] Client &client, const char *const name = args[0]; unsigned from = args.ParseUnsigned(1); - spl_remove_index(name, from); + PlaylistFileEditor editor(name, PlaylistFileEditor::LoadMode::YES); + editor.RemoveIndex(from); + editor.Save(); return CommandResult::OK; } @@ -189,7 +191,14 @@ handle_playlistmove([[maybe_unused]] Client &client, unsigned from = args.ParseUnsigned(1); unsigned to = args.ParseUnsigned(2); - spl_move_index(name, from, to); + if (from == to) + /* this doesn't check whether the playlist exists, but + what the hell.. */ + return CommandResult::OK; + + PlaylistFileEditor editor(name, PlaylistFileEditor::LoadMode::YES); + editor.MoveIndex(from, to); + editor.Save(); return CommandResult::OK; }