command/database: add optional position parameter to "searchaddpl"
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1328
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "PlaylistFile.hxx"
|
||||
#include "Interface.hxx"
|
||||
#include "song/DetachedSong.hxx"
|
||||
#include "protocol/Ack.hxx"
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -61,3 +62,22 @@ SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
|
||||
const DatabaseSelection &selection,
|
||||
const char *playlist_name,
|
||||
unsigned position)
|
||||
{
|
||||
PlaylistFileEditor editor{
|
||||
playlist_name,
|
||||
PlaylistFileEditor::LoadMode::TRY,
|
||||
};
|
||||
|
||||
if (position > editor.size())
|
||||
throw ProtocolError{ACK_ERROR_ARG, "Bad position"};
|
||||
|
||||
if (SearchInsertIntoPlaylist(db, storage, selection,
|
||||
editor, position) > 0)
|
||||
editor.Save();
|
||||
}
|
||||
|
||||
@@ -42,4 +42,10 @@ SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
|
||||
PlaylistFileEditor &playlist,
|
||||
unsigned position);
|
||||
|
||||
void
|
||||
SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
|
||||
const DatabaseSelection &selection,
|
||||
const char *playlist_name,
|
||||
unsigned position);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user