int_32 Shell_dir_r(int_32 argc, char_ptr argv[]) { boolean print_usage, shorthelp = FALSE; TIME_STRUCT time, time_new; char full_name[255]; print_usage = Shell_check_help_request(argc, argv, &shorthelp); /* Check if help should be printed out */ if (print_usage) { if (shorthelp) { printf("%s dir \n", argv[0]); } else { printf("Usage: %s dir \n", argv[0]); printf("\tList all the files in the directory.\n"); printf(" dir = directory to be listed.\n"); } } set_file_filter(ext_wantted); _time_get(&time); if (0 == strcmp(argv[2], "next")) get_next_file_name(argv[1], full_name); else if (0 == strcmp(argv[2], "prev")) get_prev_file_name(argv[1], full_name); _time_get(&time_new); printf("%s\n", full_name); /* if(NULL != fopen(full_name, "r")){ printf("The file %s opened.\n", full_name); } */ /* printf("Taken %dms to list %d directories and %d files.\n", (time_new.SECONDS - time.SECONDS) * 1000 + (time_new.MILLISECONDS - time.MILLISECONDS), dir_listed, file_listed ); */ return (SHELL_EXIT_SUCCESS); }
void sd_file_search_task(uint_32 para) { lp_param_t * lpp_param = (lp_param_t *)para; char * path = (char *)lpp_param->path; set_file_filter((char **) ext_wantted); while (1) { _lwevent_wait_ticks( &player_event, PLAYER_EVENT_MSK_NEXT_BTN_PRESSED | PLAYER_EVENT_MSK_PREV_BTN_PRESSED | PLAYER_EVENT_MSK_SD_FS_MOUNTED |PLAYER_EVENT_MSK_SEARCH_TASK_QUIT, FALSE, 0); full_path[0] = '\0'; if (player_event.VALUE & PLAYER_EVENT_MSK_SEARCH_TASK_QUIT) { //printf("search task %d exit\n",lpp_param->lp_type); _lwevent_clear(&player_event, PLAYER_EVENT_MSK_SEARCH_TASK_QUIT); goto exit_search; } printf("search lock umount at %d\n",lpp_param->lp_type); _lwsem_wait(lpp_param->mfs_io_sem); if (player_event.VALUE & PLAYER_EVENT_MSK_NEXT_BTN_PRESSED) { //get_next_file_name("a:\\", full_path); get_next_file_name(path, full_path); _lwevent_clear(&player_event, PLAYER_EVENT_MSK_NEXT_BTN_PRESSED); //printf("search id1\n"); } else if (player_event.VALUE & PLAYER_EVENT_MSK_PREV_BTN_PRESSED) { //get_prev_file_name("a:\\", full_path); get_prev_file_name(path, full_path); _lwevent_clear(&player_event, PLAYER_EVENT_MSK_PREV_BTN_PRESSED); //printf("search id2\n"); } else if (player_event.VALUE & PLAYER_EVENT_MSK_SD_FS_MOUNTED) { //get_next_file_name("a:\\", full_path); get_next_file_name(path, full_path); _lwevent_clear(&player_event, PLAYER_EVENT_MSK_SD_FS_MOUNTED); //printf("MOUNTED! 1: %s\n", full_path); } printf("search unlock umount at %d\n",lpp_param->lp_type); _lwsem_post(lpp_param->mfs_io_sem); /* If found*/ if (full_path[0] != '\0') {_lwevent_set(&player_event, PLAYER_EVENT_MSK_SONG_READY); printf("search y\n"); } else printf("search n\n"); } exit_search: fs_walker_clear(); printf("sd_file_search_task exit.\n"); //printf("__guoyifang__: sd_file_search_task %d set SEARCH_TASK_KILLED.\n",lpp_param->lp_type); _lwevent_set(&player_event, PLAYER_EVENT_MSK_SEARCH_TASK_KILLED); //_task_block(); //wait for being destroyed }
GSList * show_file_chooser (const gchar *title, enum GtkuiFileChooserType type, gboolean select_multiple) { GtkFileChooserAction action; switch (type) { case GTKUI_FILECHOOSER_OPENFOLDER: action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; break; case GTKUI_FILECHOOSER_OPENFILE: case GTKUI_FILECHOOSER_LOADPLAYLIST: action = GTK_FILE_CHOOSER_ACTION_OPEN; break; case GTKUI_FILECHOOSER_SAVEPLAYLIST: action = GTK_FILE_CHOOSER_ACTION_SAVE; break; } GtkFileChooser *dlg = get_file_chooser(title, action, select_multiple); switch (type) { case GTKUI_FILECHOOSER_OPENFILE: set_file_filter (dlg, NULL); break; case GTKUI_FILECHOOSER_LOADPLAYLIST: set_file_filter_loadplaylist(dlg); break; case GTKUI_FILECHOOSER_SAVEPLAYLIST: gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dlg), TRUE); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlg), "untitled.dbpl"); set_file_filter_saveplaylist(dlg); break; } const char *conf_lastdir; switch (type) { case GTKUI_FILECHOOSER_OPENFOLDER: case GTKUI_FILECHOOSER_OPENFILE: conf_lastdir = "filechooser.lastdir"; break; case GTKUI_FILECHOOSER_LOADPLAYLIST: case GTKUI_FILECHOOSER_SAVEPLAYLIST: conf_lastdir = "filechooser.playlist.lastdir"; break; } // restore folder /* Windows: setting current folder for native filechooser here breaks restoring dirs, without it it still works fine? deadbeef->conf_lock (); gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dlg), deadbeef->conf_get_str_fast (conf_lastdir, "")); deadbeef->conf_unlock (); */ int response = run_file_chooser(dlg); // store folder gchar *folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dlg)); if (folder) { deadbeef->conf_set_str (conf_lastdir, folder); g_free (folder); } GSList *lst = NULL; if (response == GTK_RESPONSE_ACCEPT) { lst = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dlg)); #if defined USE_GTK_NATIVE_FILE_CHOOSER && defined __MINGW32__ // workaround: Gtk's win32 file chooser uses g_slist_prepend internally and forgets to reverse it before returning lst = g_slist_reverse (lst); #endif } destroy_file_chooser (dlg); return lst; }