be more verbose while deleting items in browser
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -536,7 +537,10 @@ void Browser::ClearDirectory(const std::string &path) const
|
|||||||
lstat(full_path.c_str(), &file_stat);
|
lstat(full_path.c_str(), &file_stat);
|
||||||
if (S_ISDIR(file_stat.st_mode))
|
if (S_ISDIR(file_stat.st_mode))
|
||||||
ClearDirectory(full_path);
|
ClearDirectory(full_path);
|
||||||
remove(full_path.c_str());
|
if (remove(full_path.c_str()) == 0)
|
||||||
|
ShowMessage("Deleting \"%s\"...", full_path.c_str());
|
||||||
|
else
|
||||||
|
ShowMessage("Couldn't remove \"%s\": %s", full_path.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -584,7 +584,8 @@ int main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
LockStatusbar();
|
LockStatusbar();
|
||||||
Statusbar() << "Delete " << (item.type == itSong ? "file" : "directory") << " \"" << (item.type == itSong ? item.song->GetName() : item.name) << "\" ? [y/n] ";
|
string name = item.type == itSong ? item.song->GetName() : item.name;
|
||||||
|
Statusbar() << "Delete " << (item.type == itSong ? "file" : "directory") << " \"" << name << "\" ? [y/n] ";
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
int in = 0;
|
int in = 0;
|
||||||
do
|
do
|
||||||
@@ -595,8 +596,6 @@ int main(int argc, char *argv[])
|
|||||||
while (in != 'y' && in != 'n');
|
while (in != 'y' && in != 'n');
|
||||||
if (in == 'y')
|
if (in == 'y')
|
||||||
{
|
{
|
||||||
ShowMessage("Deleting...");
|
|
||||||
|
|
||||||
string path;
|
string path;
|
||||||
if (!Config.local_browser)
|
if (!Config.local_browser)
|
||||||
path = Config.mpd_music_dir;
|
path = Config.mpd_music_dir;
|
||||||
@@ -607,14 +606,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (remove(path.c_str()) == 0)
|
if (remove(path.c_str()) == 0)
|
||||||
{
|
{
|
||||||
ShowMessage("%s has been deleted!", item.type == itSong ? "File" : "Directory");
|
ShowMessage("\"%s\" has been successfuly deleted!", name.c_str());
|
||||||
if (!Config.local_browser)
|
if (!Config.local_browser)
|
||||||
Mpd->UpdateDirectory(myBrowser->CurrentDir());
|
Mpd->UpdateDirectory(myBrowser->CurrentDir());
|
||||||
else
|
else
|
||||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ShowMessage("Deletion failed: %s", strerror(errno));
|
ShowMessage("Couldn't remove \"%s\": %s", name.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ShowMessage("Aborted!");
|
ShowMessage("Aborted!");
|
||||||
|
|||||||
Reference in New Issue
Block a user