Index: apps/onplay.c =================================================================== --- apps/onplay.c (revision 18371) +++ apps/onplay.c (working copy) @@ -586,6 +586,63 @@ } #endif +static void move_to_favorite_folder(short int favorite_type) +{ + char new_filename[MAX_PATH]; + + /* Strip the file path from the full filename */ + char* filename_without_path = strrchr(selected_file, '/'); + + /* Set the path of the favorite folder according to the rating requested */ + if (favorite_type == 1) { + strcpy(new_filename, "/favorite_3_star_songs"); + } else if (favorite_type == 2) { + strcpy(new_filename, "/favorite_4_star_songs"); + } else if (favorite_type == 3) { + strcpy(new_filename, "/favorite_5_star_songs"); + } + + /* Now check if the favorite folder already exists and create it accordingly */ + if (dir_exists(new_filename) == false && mkdir(new_filename) < 0) { + splash(HZ*3, "Unable to created favorite directory!"); + return; + } + + /* Now set the full path of the file in the favorite folder */ + strcat(new_filename, filename_without_path); + + /* Finally, move the file to the favorite folder */ + if (rename(selected_file, new_filename) < 0) { + splash(HZ*3, "Unable to move the file to favorite!"); + } else { + if (favorite_type == 1) { + splash(HZ*3, "File moved to 3-Star folder"); + } else if (favorite_type == 2) { + splash(HZ*3, "File moved to 4-Star folder"); + } else if (favorite_type == 3) { + splash(HZ*3, "File moved to 5-Star folder"); + } + } +} + +static bool move_to_favorite_good(void) +{ + move_to_favorite_folder(1); + return false; +} + +static bool move_to_favorite_better(void) +{ + move_to_favorite_folder(2); + return false; +} + +static bool move_to_favorite_best(void) +{ + move_to_favorite_folder(3); + return false; +} + static bool rename_file(void) { char newname[MAX_PATH]; @@ -1006,6 +1063,13 @@ /* CONTEXT_[TREE|ID3DB] items */ static int clipboard_callback(int action,const struct menu_item_ex *this_item); + +MENUITEM_FUNCTION(move_to_favorite_good_item, 0, "Move to 3-Star Folder", + move_to_favorite_good, NULL, clipboard_callback, Icon_NOICON); +MENUITEM_FUNCTION(move_to_favorite_better_item, 0, "Move to 4-Star Folder", + move_to_favorite_better, NULL, clipboard_callback, Icon_NOICON); +MENUITEM_FUNCTION(move_to_favorite_best_item, 0, "Move to 5-Star Folder", + move_to_favorite_best, NULL, clipboard_callback, Icon_NOICON); MENUITEM_FUNCTION(rename_file_item, 0, ID2P(LANG_RENAME), rename_file, NULL, clipboard_callback, Icon_NOICON); MENUITEM_FUNCTION(clipboard_cut_item, 0, ID2P(LANG_CUT), @@ -1078,6 +1142,9 @@ (this_item == &rename_file_item) || (this_item == &clipboard_cut_item) || (this_item == &clipboard_copy_item) || + (this_item == &move_to_favorite_best_item) || + (this_item == &move_to_favorite_better_item) || + (this_item == &move_to_favorite_good_item) || (this_item == &add_to_faves_item) ) { @@ -1141,6 +1208,9 @@ #endif &bookmark_menu, &browse_id3_item, &list_viewers_item, &delete_file_item, &view_cue_item, + &move_to_favorite_best_item, + &move_to_favorite_better_item, + &move_to_favorite_good_item, #ifdef HAVE_PITCHSCREEN &pitch_screen_item, #endif