diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2010-07-12 07:48:10 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2010-07-12 07:48:10 +0200 |
commit | f627dc854d3dad658c89196ff93112ae6cc97a4a (patch) | |
tree | a9e9b59a1f1afa5c4658cad483aabbae1854e874 /src/browser.cpp | |
parent | 5d37d56c642bc3e1853d09e684d6cd165ee3b5f6 (diff) |
browser: add support for deleting group of selected items
Diffstat (limited to 'src/browser.cpp')
-rw-r--r-- | src/browser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index c409dba5..57c850b6 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -520,6 +520,27 @@ void Browser::ChangeBrowseMode() GetDirectory(itsBrowsedDir); RedrawHeader = 1; } + +bool Browser::DeleteItem(const MPD::Item &item) +{ + // parent dir + if (item.type == itDirectory && item.song) + return false; + + // playlist creatd by mpd + if (!isLocal() && item.type == itPlaylist && CurrentDir() == "/") + return Mpd.DeletePlaylist(locale_to_utf_cpy(item.name)); + + std::string path; + if (!isLocal()) + path = Config.mpd_music_dir; + path += item.type == itSong ? item.song->GetFile() : item.name; + + if (item.type == itDirectory) + ClearDirectory(path); + + return remove(path.c_str()) == 0; +} #endif // !WIN32 void Browser::UpdateItemList() |