diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 90dd6034..cd35a9d4 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -563,6 +563,14 @@ int Connection::AddSong(const Song &s) return !s.Empty() ? (AddSong((!s.isFromDB() ? "file://" : "") + (s.Localized() ? locale_to_utf_cpy(s.GetFile()) : s.GetFile()))) : -1; } +void Connection::Add(const std::string &path) const +{ + if (!isConnected) + return; + mpd_sendAddCommand(itsConnection, path.c_str()); + mpd_finishCommand(itsConnection); +} + bool Connection::AddRandomSongs(size_t number) { if (!isConnected && !number) diff --git a/src/mpdpp.h b/src/mpdpp.h index 2bbca866..071ab387 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -153,6 +153,7 @@ namespace MPD int AddSong(const std::string &); // returns id of added song int AddSong(const Song &); // returns id of added song bool AddRandomSongs(size_t); + void Add(const std::string &path) const; void Delete(int) const; void DeleteID(int) const; void Delete(const std::string &, int) const; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 43847223..612983a9 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1061,20 +1061,14 @@ int main(int argc, char *argv[]) UnlockStatusbar(); if (!path.empty()) { - SongList list; - Mpd.GetDirectoryRecursive(path, list); - if (!list.empty()) - myPlaylist->Add(list, 0); - else - { - if (myScreen == myPlaylistEditor) - Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path); - else - Mpd.AddSong(path); - } if (myScreen == myPlaylistEditor) + { + Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path); myPlaylistEditor->Content->Clear(0); // make it refetch content of playlist - FreeSongList(list); + } + else + Mpd.Add(path); + UpdateStatusImmediately = 1; } } else if (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))