Index: apps/onplay.c =================================================================== --- apps/onplay.c (revision 17087) +++ apps/onplay.c (working copy) @@ -512,9 +512,9 @@ return result; } - +enum delete_types{E_DIR, E_FILE, E_FILE_WSN}; /* share code for file and directory deletion, saves space */ -static bool delete_handler(bool is_dir) +static bool delete_handler(enum delete_types type) { char *lines[]={ ID2P(LANG_REALLY_DELETE), @@ -534,7 +534,7 @@ gui_syncsplash(0, str(LANG_DELETING)); int res; - if (is_dir) + if (type==E_DIR) { char pathname[MAX_PATH]; /* space to go deep */ cpu_boost(true); @@ -543,23 +543,49 @@ cpu_boost(false); } else + { res = remove(selected_file); + if(type==E_FILE_WSN){ + struct dirent *entry; + char fullpath[MAX_PATH]; + strcpy(fullpath, selected_file); + char* filename = strrchr(fullpath,'/'); + *filename++ = 0; /* path0filename.ext */ + const int len = strrchr(filename,'.') - filename; + DIR* dir = opendir(filename-fullpath>1 ? fullpath:"/"); + *(filename-1) = '/'; /* path/filename.ext */ + if (dir) { + while((entry=readdir(dir))!=0) + { + if(strncasecmp(entry->d_name,filename,len)==0){ /* same name? */ + strcpy(filename,entry->d_name); /* path/filename.ext */ + remove(fullpath); + } + } + closedir(dir); + } + } + } if (!res) { onplay_result = ONPLAY_RELOAD_DIR; } return false; } +/* deletes all files With the Same Name: .* */ +static bool delete_files_wsn(void) +{ + return delete_handler(E_FILE_WSN); +} - static bool delete_file(void) { - return delete_handler(false); + return delete_handler(E_FILE); } static bool delete_dir(void) { - return delete_handler(true); + return delete_handler(E_DIR); } #if LCD_DEPTH > 1 @@ -1023,6 +1049,8 @@ clipboard_copy, NULL, clipboard_callback, Icon_NOICON); MENUITEM_FUNCTION(clipboard_paste_item, 0, ID2P(LANG_PASTE), clipboard_paste, NULL, clipboard_callback, Icon_NOICON); +MENUITEM_FUNCTION(delete_files_wsn_item, 0, "Delete .*", + delete_files_wsn, NULL, clipboard_callback, Icon_NOICON); MENUITEM_FUNCTION(delete_file_item, 0, ID2P(LANG_DELETE), delete_file, NULL, clipboard_callback, Icon_NOICON); MENUITEM_FUNCTION(delete_dir_item, 0, ID2P(LANG_DELETE_DIR), @@ -1121,6 +1149,7 @@ ) { if ((this_item == &delete_file_item) || + (this_item == &delete_files_wsn_item) || (this_item == &list_viewers_item)) { return action; @@ -1140,7 +1169,8 @@ #ifdef HAVE_TAGCACHE &rating_item, #endif - &bookmark_menu, &browse_id3_item, &delete_file_item, &view_cue_item, + &bookmark_menu, &browse_id3_item, &delete_file_item, + &delete_files_wsn_item, &view_cue_item, #ifdef HAVE_PITCHSCREEN &pitch_screen_item, #endif @@ -1153,7 +1183,8 @@ onplaymenu_callback, Icon_file_view_menu, &tree_playlist_menu, &cat_playlist_menu, &rename_file_item, &clipboard_cut_item, &clipboard_copy_item, - &clipboard_paste_item, &delete_file_item, &delete_dir_item, + &clipboard_paste_item, &delete_file_item, &delete_files_wsn_item, + &delete_dir_item, #if LCD_DEPTH > 1 &set_backdrop_item, #endif