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 }
void process_copy_out (void) { int res; /* result of functions */ dynamic_string input_name; /* name of file read from stdin */ int handle; /* output file descriptor */ struct stat stat_info; /* temporary stat record */ assert (header_writer != NULL); assert (eof_writer != NULL); /* Initialize the copy out. */ ds_init (&input_name, 128); #ifdef __MSDOS__ setmode (archive_des, O_BINARY); #endif #if DOSWIN if (!isatty (archive_des)) setmode (archive_des, O_BINARY); #endif /* Check whether the output file might be a tape. */ handle = archive_des; if (_isrmt (handle)) { output_is_special = 1; output_is_seekable = 0; } else { if (fstat (handle, &stat_info)) error (1, errno, _("standard output is closed")); output_is_special = ( #ifdef S_ISBLK S_ISBLK (stat_info.st_mode) || #endif S_ISCHR (stat_info.st_mode)); output_is_seekable = S_ISREG (stat_info.st_mode); } #if DOSWIN /* We might as well give the user an opportunity to recover from "No space on device" even if they are writing to disk files. It is specifically handy with floppies. */ output_is_special = !isatty (handle); #endif if (append_option) { process_copy_in (); prepare_append (handle); } /* Copy files with names read from stdin. */ while (get_next_file_name (&input_name)) dump_one_file (1, handle, &input_name); writeout_final_defers (handle); /* The collection is complete; append the trailer. */ (*eof_writer) (handle); /* Fill up the output block. */ tape_clear_rest_of_block (handle); tape_empty_output_buffer (handle); if (dot_option) fputc ('\n', stderr); if (! quiet_option) { res = (output_bytes + io_block_size - 1) / io_block_size; if (res == 1) fprintf (stderr, _("1 block\n")); else fprintf (stderr, _("%d blocks\n"), res); } }