summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deadbeef.h5
-rw-r--r--plugins/gtkui/actionhandlers.c25
2 files changed, 23 insertions, 7 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 8a563aef..2ed468cb 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -868,7 +868,10 @@ typedef struct {
struct DB_plugin_s *(*plug_get_for_id) (const char *id);
// misc utilities
- int (*is_local_file) (const char *fname); // returns 1 for local filename, 0 otherwise
+ // returns 1 if the track is represented as a local file
+ // returns 0 if it's a remote file, e.g. a network stream
+ // since API 1.5 it also returns 1 for vfs tracks, e.g. from ZIP files
+ int (*is_local_file) (const char *fname);
// pcm utilities
int (*pcm_convert) (const ddb_waveformat_t * inputfmt, const char *input, const ddb_waveformat_t *outputfmt, char *output, int inputsize);
diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c
index 879f8f09..88214a1c 100644
--- a/plugins/gtkui/actionhandlers.c
+++ b/plugins/gtkui/actionhandlers.c
@@ -508,8 +508,9 @@ action_delete_from_disk_handler_cb (void *data) {
while (it) {
const char *uri = deadbeef->pl_find_meta (it, ":URI");
if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (uri)) {
- unlink (uri);
- deadbeef->plt_remove_item (plt, it);
+ if (!unlink (uri)) {
+ deadbeef->plt_remove_item (plt, it);
+ }
}
DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
deadbeef->pl_item_unref (it);
@@ -523,8 +524,19 @@ action_delete_from_disk_handler_cb (void *data) {
while (it) {
const char *uri = deadbeef->pl_find_meta (it, ":URI");
if (deadbeef->is_local_file (uri)) {
- unlink (uri);
- deadbeef->plt_remove_item (plt, it);
+ if (!unlink (uri)) {
+ deadbeef->plt_remove_item (plt, it);
+ }
+// FIXME: this dialog should allow something like "cancel" and "ignore all", then
+// it will be usable
+// else {
+// GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Can't delete the file. Perhaps it doesn't exist, read-only, or part of read-only VFS, or all of the above."));
+// gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), uri);
+// gtk_window_set_title (GTK_WINDOW (dlg), _("Warning"));
+//
+// int response = gtk_dialog_run (GTK_DIALOG (dlg));
+// gtk_widget_destroy (dlg);
+// }
}
DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
deadbeef->pl_item_unref (it);
@@ -540,8 +552,9 @@ action_delete_from_disk_handler_cb (void *data) {
if (deadbeef->is_local_file (uri)) {
int idx = deadbeef->plt_get_item_idx (plt, it, PL_MAIN);
if (idx != -1) {
- unlink (uri);
- deadbeef->plt_remove_item (plt, it);
+ if (!unlink (uri)) {
+ deadbeef->plt_remove_item (plt, it);
+ }
}
}
deadbeef->pl_item_unref (it);