//! This function resets the selection pointer, so "no file is selected" in file list FLAT //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_flat_reset( void ) { while( 0 != fs_g_nav.u8_flat_dir_level ) { fs_g_nav.u8_flat_dir_level--; nav_dir_gotoparent(); } fs_g_nav.u16_flat_pos_offset = 0; return nav_filelist_reset(); }
//! This function sets the pointer to a limit. //! //! @param b_direction direction of navigation (FS_FIND_NEXT or FS_FIND_PREV) //! //! @return true if a file is selected //! false otherwise //! static navauto_mov_explorer_rec_t navauto_mov_explorer_limit(bool b_direction) { // Reset the selection nav_filelist_reset(); // Goes to the root directory while(navauto_mov_explorer_updir(b_direction) != NAVAUTO_MOV_EXPLORER_ERROR); // Update directory level g_navauto_u16_dir_level = g_navauto_u16_dir_level_root; // Call back the recursive function return NAVAUTO_MOV_EXPLORER_RECURSIVE; }
//! This function goes to a position in the play list //! //! @param u16_position position in play list to go //! bool pl_nav_setpos( uint16_t u16_position ) { uint8_t nav_id_save; if( (0 == u16_position ) || (pl_g_u16_list_size < u16_position) ) { fs_g_status = FS_ERR_PL_OUT_LST; return false; } if( pl_g_u16_list_sel == u16_position ) return true; // Reset previous selection nav_filelist_reset(); // Go to play list file navigator nav_id_save = nav_get(); nav_select( FS_NAV_ID_PLAYLIST ); if( pl_g_u16_list_sel > u16_position ) { // Go to at the beginning of text file reader_txt_beg(); pl_g_u16_list_sel = 0; } while( pl_g_u16_list_sel != u16_position ) { FS_STRING sz_path; bool next_pos = false; if( 0 != file_eof() ) { nav_select( nav_id_save ); // Re select the previous navigator return false; } if (pl_g_u16_list_sel+1 == u16_position) { next_pos = pl_main_readline(PL_MAIN_READLINE_OPT_GOTOPATH, nav_id_save, &sz_path, NULL); if (sz_path) PLAYLIST_BUF_FREE(sz_path); } else next_pos = pl_main_readline(PL_MAIN_READLINE_OPT_CHECKLINE, 0, NULL, NULL); if (next_pos) pl_g_u16_list_sel++; // Add a file } nav_select( nav_id_save ); // Re select the previous navigator return true; }
//! This function goes to the parent directory //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! //! @verbatim //! After the selected file is the first entry of the new file list FLAT //! @endverbatim //! bool nav_flat_gotoparent( void ) { _MEM_TYPE_SLOW_ Fs_index index; index = nav_getindex(); while( 0 != fs_g_nav.u8_flat_dir_level ) { fs_g_nav.u8_flat_dir_level--; nav_dir_gotoparent(); } if( !nav_dir_gotoparent() ) { nav_gotoindex( &index ); return false; } // Go to at the beginning of FLAT list fs_g_nav.u8_flat_dir_level = 0; fs_g_nav.u16_flat_pos_offset = 0; nav_filelist_reset(); nav_flat_next(); return true; }
//! @brief This function manages the ls command //! //! @param b_more enable the '|more' management when true otherwise no '|more' management //! void ushell_cmd_ls( bool b_more ) { uint8_t str_char[MAX_FILE_PATH_LENGTH]; uint16_t u16_i,u16_nb_file,u16_nb_dir,last_i; uint8_t ext_filter=false; //** Print drive name printf("%c: volume is %s\r\n", 'a'+nav_drive_get(), mem_name(nav_drive_get()) ); printf("Drive uses "); switch (nav_partition_type()) { case FS_TYPE_FAT_12: printf("FAT12\n\r"); break; case FS_TYPE_FAT_16: printf("FAT16\n\r"); break; case FS_TYPE_FAT_32: printf("FAT32\n\r"); break; default: printf("an unknown partition type\r\n"); return; } //** Print directory name if( !nav_dir_name( (FS_STRING)str_char, MAX_FILE_PATH_LENGTH ) ) return; printf("Dir name is %s\n\r",str_char); //** Check extension filter in extra parameters if(g_s_arg[0][0]!=0) { if(g_s_arg[0][0] == '*' && g_s_arg[0][1]=='.') { ext_filter=true; for(u16_i=2; u16_i<USHELL_SIZE_CMD_LINE; u16_i++) { g_s_arg[0][u16_i-2]=g_s_arg[0][u16_i]; } } } //** Print files list printf(" Size Name\n\r"); // Init loop at the beginning of directory nav_filelist_reset(); u16_nb_file=0; u16_nb_dir=0; last_i=0; // For each file in list while( nav_filelist_set(0,FS_FIND_NEXT) ) { if(!ext_filter) { // No extension filter if( nav_file_isdir() ) { printf("Dir "); u16_nb_dir++; // count the number of directory }else{ printf(" "); } } else { // If extension filter then ignore directories if(nav_file_isdir()) continue; // Check extension if(!nav_file_checkext((FS_STRING)g_s_arg[0])) continue; } u16_nb_file++; // count the total of files (directories and files) // Check 'more' step if( b_more && ((u16_nb_file%USHELL_NB_LINE)==0) && (u16_nb_file!=0) && (last_i != u16_nb_file) ) { last_i=u16_nb_file; if( !ushell_more_wait() ) return; // Exit LS command } // Display file nav_file_name((FS_STRING)str_char, MAX_FILE_PATH_LENGTH, FS_NAME_GET, true); printf("%10lu %s\n\r", nav_file_lgt(), str_char); } // Display total number printf(" %4i Files\r\n", u16_nb_file-u16_nb_dir ); printf(" %4i Dir\r\n", u16_nb_dir ); }
//! @brief Synchronize a path with an other path //! //! @return true if success //! bool ushell_cmd_sync( void ) { Fs_index sav_index; uint8_t u8_folder_level = 0; if( g_s_arg[0][0] == 0 ) return false; if( g_s_arg[1][0] == 0 ) return false; // Add '\' at the end of path, else the nav_setcwd select the directory but don't enter into. ushell_path_valid_syntac( g_s_arg[0] ); ushell_path_valid_syntac( g_s_arg[1] ); printf("Synchronize folders:\n\r"); sav_index = nav_getindex(); // Save the position // Select source directory in COPYFILE navigator handle nav_select( FS_NAV_ID_COPYFILE ); printf("Select source directory\n\r"); if( !nav_setcwd( (FS_STRING)g_s_arg[0], true, false ) ) goto ushell_cmd_sync_error; nav_filelist_reset(); // Select destination directory in USHELL navigator handle nav_select( FS_NAV_ID_USHELL_CMD ); printf("Select destination directory\n\r"); if( !nav_setcwd( (FS_STRING)g_s_arg[1], true, true ) ) goto ushell_cmd_sync_error; nav_filelist_reset(); // loop to scan and create ALL folders and files while(1) { while(1) { // Loop to Search files or directories // Reselect Source nav_select( FS_NAV_ID_COPYFILE ); if( nav_filelist_set( 0 , FS_FIND_NEXT ) ) break; // a next file and directory is found // No other dir or file in current dir then go to parent dir on Source and Destination disk if( 0 == u8_folder_level ) { // end of update folder //********* END OF COPY ************** goto ushell_cmd_sync_finish; } printf("Go to parent\n\r"); // Remark, nav_dir_gotoparent() routine go to in parent dir and select the children dir in list u8_folder_level--; if( !nav_dir_gotoparent() ) goto ushell_cmd_sync_error; // Select Destination navigator and go to the same dir of Source nav_select( FS_NAV_ID_USHELL_CMD ); if( !nav_dir_gotoparent() ) goto ushell_cmd_sync_error; } // end of while (1) if( nav_file_isdir()) { printf("Dir found - create dir: "); //** here, a new directory is found and is selected // Get name of current selection (= dir name on Source) if( !nav_file_name( (FS_STRING)g_s_arg[0], USHELL_SIZE_CMD_LINE, FS_NAME_GET, false )) goto ushell_cmd_sync_error; // Enter in dir (on Source) if( !nav_dir_cd()) goto ushell_cmd_sync_error; u8_folder_level++; // Select Destination disk nav_select( FS_NAV_ID_USHELL_CMD ); // Create folder in Destination disk printf((char*)g_s_arg[0]); printf("\n\r"); if( !nav_dir_make( (FS_STRING )g_s_arg[0] )) { if( FS_ERR_FILE_EXIST != fs_g_status ) goto ushell_cmd_sync_error; // here, error the name exist } // Here the navigator have selected the folder on Destination if( !nav_dir_cd()) { if( FS_ERR_NO_DIR == fs_g_status ) { // FYC -> Copy impossible, because a file have the same name of folder } goto ushell_cmd_sync_error; } // here, the folder is created and the navigator is entered in this dir } else { printf("File found - copy file: "); //** here, a new file is found and is selected // Get name of current selection (= file name on Source) if( !nav_file_name( (FS_STRING)g_s_arg[0], USHELL_SIZE_CMD_LINE, FS_NAME_GET, false )) goto ushell_cmd_sync_error; printf((char*)g_s_arg[0]); printf("\n\r"); if( !nav_file_copy()) goto ushell_cmd_sync_error; // Paste file in current dir of Destination disk nav_select( FS_NAV_ID_USHELL_CMD ); while( !nav_file_paste_start( (FS_STRING)g_s_arg[0] ) ) { // Error if( fs_g_status != FS_ERR_FILE_EXIST ) goto ushell_cmd_sync_error; // File exists then deletes this one printf("File exists then deletes this one.\n\r"); if( !nav_file_del( true ) ) goto ushell_cmd_sync_error; // here, retry PASTE } // Copy running { uint8_t status; do{ status = nav_file_paste_state(false); }while( COPY_BUSY == status ); if( COPY_FINISH != status ) goto ushell_cmd_sync_error; } } // if dir OR file } // end of first while(1) ushell_cmd_sync_error: // Restore the position nav_select( FS_NAV_ID_USHELL_CMD ); nav_gotoindex(&sav_index); printf("!!!Copy fail\n\r"); return false; ushell_cmd_sync_finish: // Restore the position nav_select( FS_NAV_ID_USHELL_CMD ); nav_gotoindex(&sav_index); printf("End of copy\n\r"); return true; }
//! This function opens a file list at the current position in navigator //! //! @param b_playlist if true then the current selected file is a play list file to open //! else create a file list with files included in a disk part //! @param pos If b_playlist true, then position in the play list to start //! else folder level of the current position //! //! @return false, in case of error or file list empty //! bool navauto_open( bool b_playlist , uint16_t pos ) { Navauto_mov_state state; g_navauto_b_playlist = b_playlist; g_navauto_u16_dir_level_root = 0; g_navauto_u16_nb = 0; if( b_playlist ) { g_navauto_u16_pos = pos; if( !pl_main_open(false) ) return false; g_navauto_u16_nb = pl_nav_getnbfile(); if( 0 == g_navauto_u16_nb ) return false; if( NAVAUTO_RAND_OFF == navauto_getrand() ) { if( pl_nav_setpos( g_navauto_u16_pos )) { if( nav_filelist_validpos() ) return true; } }else{ navauto_rand_init(); } // Error position then restart at the beginning g_navauto_u16_pos = 0; } else { #if( FS_NAV_AUTOMATIC_NBFILE == ENABLE ) Fs_index index; Fs_index index2; Navauto_rand rand_mode; uint16_t u16_current_pos=0; index.u8_lun = 0xFF; // Reset index (by default no valid selected file) g_navauto_u16_dir_level = pos; rand_mode = navauto_getrand(); // Save random mode navauto_setrand( NAVAUTO_RAND_OFF ); // If no valid file then found the first valid file if( !nav_file_checkext( g_navauto_filter )) { // Go to previous position because "navauto_mov_explorer()" execute a next before search valid file if( !nav_filelist_set( 0 , FS_FIND_PREV ) ) nav_filelist_reset(); state = navauto_mov_explorer(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE); if((NAVAUTO_MOV_OK_LOOP != state.status) && (NAVAUTO_MOV_OK != state.status) ) { navauto_setrand(rand_mode); return false; // List empty } } index = nav_getindex(); // Compute the size of file list and search the position of selected file navauto_mov_explorer_reset(); // Go to beginning of loop // Note: the number of file is updated in navauto_mov_explorer() routine when the end of list is detected while( navauto_mov_explorer( FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE ).status == NAVAUTO_MOV_OK ) { index2 = nav_getindex(); // Check the current position with the selected file if( (index.u8_lun == index2.u8_lun) && (index.u32_cluster_sel_dir == index2.u32_cluster_sel_dir) && (index.u16_entry_pos_sel_file == index2.u16_entry_pos_sel_file) ) { u16_current_pos = g_navauto_u16_pos; // Save the position number found g_navauto_u16_dir_level_root = g_navauto_u16_dir_level; } } navauto_setrand(rand_mode); // Restore random mode if( 0 == g_navauto_u16_nb ) return false; // loop empty // Go to a file from file list if( NAVAUTO_RAND_OFF == navauto_getrand() ) { if( 0xFF != index.u8_lun ) { // Reselect the file selected at startup nav_gotoindex( &index ); // Go to this one g_navauto_u16_dir_level = g_navauto_u16_dir_level_root; // Update position file g_navauto_u16_pos = u16_current_pos; // Update folder level corresponding at file } // Else, the first file is already selected at the end of "compute file list size" loop return true; }else{ navauto_rand_init(); } #else Fs_index index; Navauto_rand rand_mode; rand_mode = navauto_getrand(); navauto_setrand(NAVAUTO_RAND_OFF); // If no valid file then find the first valid file if( !nav_file_checkext( g_navauto_filter )) { // Go to previous position because "navauto_mov_explorer()" execute a next before search valid file if( !nav_filelist_set( 0 , FS_FIND_PREV ) ) nav_filelist_reset(); state = navauto_mov_explorer(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE); if((NAVAUTO_MOV_OK_LOOP != state.status) && (NAVAUTO_MOV_OK != state.status) ) { navauto_setrand(rand_mode); return false; // List empty } } index = nav_getindex(); navauto_setrand(rand_mode); navauto_mov_explorer_reset(); // Compute directory level g_navauto_u16_dir_level = 0; while(nav_dir_gotoparent()) g_navauto_u16_dir_level++; g_navauto_u16_dir_level_root = g_navauto_u16_dir_level; //g_navauto_u16_dir_level = pos; // Restore index nav_gotoindex(&index); g_navauto_u16_nb = 0xFFFF; if( NAVAUTO_RAND_OFF == navauto_getrand() ) navauto_rand_init(); if( nav_file_checkext( g_navauto_filter )) { // Valid file then update position with the first position but it is not the first ! g_navauto_u16_pos = 1; return true; } #endif } // Find first file or use the random feature state = navauto_mov(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE); if((NAVAUTO_MOV_OK_LOOP != state.status) && (NAVAUTO_MOV_OK != state.status) ) return false; // List empty return true; }
//! This function opens the current selected file in the current navigator in read only mode.\n //! It is a non blocking-function that returns every n-file counted. //! //! @param u16_n The number of files to look for before returning.\n //! If it contains the special value of 0, then, it will not //! process the count of link inside the playlist. //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool pl_main_open_non_blocking(uint16_t u16_n) { ai_async_context_t ctx; uint16_t u16_current_count = 0; static uint8_t nav_id_save; typedef enum { STATE_INITIALIZATION = 0, STATE_GET_LINK_COUNT, STATE_INIT_PLAYLIST_CONTEXT, STATE_END } state_t; // If false, means it is the first call if (!ai_async_context_pop(&ctx)) ctx.state = (state_t) STATE_INITIALIZATION; // By default set the status to DONE ctx.status = CMD_DONE; switch((state_t) ctx.state) { // Initialization case STATE_INITIALIZATION: if (pl_main_isopen()) return false; // Select the play list file in "play list" navigator // Save current navigator nav_id_save = nav_get(); nav_copy(FS_NAV_ID_PLAYLIST); nav_select(FS_NAV_ID_PLAYLIST); // Make sure the selected file is a playlist if (nav_file_checkext("m3u")) pl_g_list_type = E_PL_M3U; else if (nav_file_checkext("pls")) pl_g_list_type = E_PL_PLS; else if (nav_file_checkext("smp")) pl_g_list_type = E_PL_SMP; else { ctx.status = CMD_EXECUTING; ctx.state = (state_t) STATE_END; break; } // Open list if (!reader_txt_open(true)) { ctx.status = CMD_EXECUTING; ctx.state = (state_t) STATE_END; break; } pl_g_u16_list_size = 0; ctx.status = CMD_EXECUTING; if (u16_n) ctx.state = (state_t) STATE_GET_LINK_COUNT; else ctx.state = (state_t) STATE_INIT_PLAYLIST_CONTEXT; break; case STATE_GET_LINK_COUNT: u16_current_count = 0; nav_select(FS_NAV_ID_PLAYLIST); while (!file_eof() && u16_current_count < u16_n) { if (pl_main_readline(PL_MAIN_READLINE_OPT_CHECKLINE, 0, NULL, NULL)) pl_g_u16_list_size++; // Check if an error occurred during the reading else if (fs_g_status == FS_ERR_FS) { // Error file system ctx.status = CMD_EXECUTING; ctx.state = (state_t) STATE_END; break; } u16_current_count++; } ctx.status = CMD_EXECUTING; if (file_eof()) ctx.state = (state_t) STATE_INIT_PLAYLIST_CONTEXT; break; case STATE_INIT_PLAYLIST_CONTEXT: nav_select(FS_NAV_ID_PLAYLIST); // Go to at the beginning of text file reader_txt_beg(); // Don't select a file pl_g_u16_list_sel = 0; // Play list file is opened pl_g_list_is_open = true; // Re select the previous navigator nav_select(nav_id_save); nav_filelist_reset(); break; case STATE_END: // Re select the previous navigator nav_select(nav_id_save); break; } if (ctx.status == CMD_EXECUTING) { if (!ai_async_context_push(&ctx)) return false; } return pl_g_list_is_open; }
//! This function adds files in play list //! //! @param sz_filterext add file only corresponding to the extension filter //! @param u8_mode PL_ADD_FILE, PL_ADD_DIR, PL_ADD_SUBDIR //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! //! @verbatim //! It is possible to select a file or all files in a directory //! @endverbatim //! bool pl_add( const FS_STRING sz_filterext , uint8_t u8_mode ) { uint8_t nav_id_save; uint8_t u8_folder_level; if( !pl_main_modify() ) return false; nav_id_save = nav_get(); // Check last character of file nav_select( FS_NAV_ID_PLAYLIST ); if( 0!=nav_file_lgt() ) { #if( PL_UNICODE == true) file_string_unicode(); file_seek( 2, FS_SEEK_END); if( '\n' != file_getc()) { file_seek( 2, FS_SEEK_END); file_putc('\n'); } file_string_ascii(); #else file_seek( 1, FS_SEEK_END); if( '\n' != file_getc()) { file_seek( 1, FS_SEEK_END); file_putc('\n'); } #endif } nav_select( nav_id_save ); // Get path of play list file and check with current to create a relative path if( PL_ADD_FILE == u8_mode ) goto pl_add_file; // Add all files valid in current dir u8_folder_level = 0; nav_filelist_reset(); while(1) { while(1) { if( nav_filelist_set( 0 , FS_FIND_NEXT ) ) break; // a next file and directory is found // No other dir or file in current dir then go to parent dir if( 0 == u8_folder_level ) goto pl_add_end; // end of ADD // Remark, nav_dir_gotoparent() routine go to in parent dir and select the children dir in list u8_folder_level--; if( !nav_dir_gotoparent() ) return false; } if( nav_file_isdir()) { if( PL_ADD_SUBDIR == u8_mode ) { // Enter in sub dir if( !nav_dir_cd()) return false; u8_folder_level++; } } else { pl_add_file: if( nav_file_checkext( sz_filterext ) ) { // It is a valid file // Get name of current file #if( (FS_ASCII == true) && (FS_UNICODE == true) && (PL_UNICODE == false) ) nav_string_ascii(); #endif nav_getcwd( (FS_STRING)pl_cache_path, PL_CACHE_PATH_MAX_SIZE, true ); #if( (FS_ASCII == true) && (FS_UNICODE == true) && (PL_UNICODE == false) ) nav_string_unicode(); #endif // Write path in file list nav_select( FS_NAV_ID_PLAYLIST ); #if( PL_UNICODE == true) file_string_unicode(); #endif if( file_puts(pl_cache_path)) file_putc('\n'); #if( PL_UNICODE == true) file_string_ascii(); #endif nav_select( nav_id_save ); pl_g_u16_list_size++; } if( PL_ADD_FILE == u8_mode ) goto pl_add_end; } // if dir OR file } // end of first while(1) pl_add_end: // Go to beginning of file AND no file selected nav_select( FS_NAV_ID_PLAYLIST ); file_seek( 0 , FS_SEEK_SET ); pl_g_u16_list_sel = 0; nav_select( nav_id_save ); return true; }
//! This function reads and checks the next line //! //! @param opt PL_MAIN_READLINE_OPT_CHECKLINE to check the next line in the file.\n //! PL_MAIN_READLINE_OPT_READSTRING to read the string in the text file.\n //! PL_MAIN_READLINE_OPT_GOTOPATH to read, check and goto the path. //! @param id_nav ID navigator to update with the selected file (ignore if b_gotopatch == false) //! @param sz_path Address of the string returned. It is used only if PL_MAIN_READLINE_OPT_READSTRING or //! PL_MAIN_READLINE_OPT_GOTOPATH options are specified. //! @param u16_size_line The length of the path. If this parameter is NULL, then the length is not returned. //! //! @return true if a line with a correct path //! false line ignored or end of file //! bool pl_main_readline( readline_opt_t opt, uint8_t id_nav, FS_STRING *sz_path, uint16_t *u16_size_line ) { uint16_t line_beg[8]; // Contains first characters of the line uint32_t u32_file_pos; uint16_t u16_alt_length = 0; uint8_t u8_pos_path_in_line = 0; // Set output to NULL to specify if there is an error *sz_path = NULL; // Read the 3 first char in the line u32_file_pos = file_getpos(); if( E_PL_M3U == pl_g_list_type ) { // M3U path lines = "path\file" // M3U comment lines = "#..." u16_alt_length = reader_txt_get_line( true, (FS_STRING)line_beg, 2 ); if( (2 > u16_alt_length) // The line size is not correct || ('#' == line_beg[0]) ) // It is a comment line { return false; } u8_pos_path_in_line=0; } if( (E_PL_PLS == pl_g_list_type) || (E_PL_SMP == pl_g_list_type) ) { // PLS path lines = "Filexxx=path\file" // SMP path lines = "File=path\file" u16_alt_length = reader_txt_get_line( true, (FS_STRING)line_beg, 8 ); if(6 > u16_alt_length) // The line size can't contain a path line return false; // Check if it is a path line if( ('F' != line_beg[0]) || ('i' != line_beg[1]) || ('l' != line_beg[2]) || ('e' != line_beg[3]) ) { return false; } u8_pos_path_in_line=5; if('=' != line_beg[4]) { u8_pos_path_in_line++; if('=' != line_beg[5]) { u8_pos_path_in_line++; if('=' != line_beg[6]) { u8_pos_path_in_line++; if('=' != line_beg[7]) return false; } } } } // Here, the line contains a path // Store the length of the line if a buffer is set if (u16_size_line) *u16_size_line = u16_alt_length - u8_pos_path_in_line; if (opt == PL_MAIN_READLINE_OPT_CHECKLINE) return true; // else go to path // Read all characters in line file_seek( u32_file_pos, FS_SEEK_SET ); *sz_path = PLAYLIST_BUF_ALLOC( u16_alt_length * (Is_unicode? 2 : 1 ) ); if( NULL == *sz_path ) return false; // no enough memory, impossible to store the path but path present in line if( 0 == reader_txt_get_line( (FS_UNICODE==true), *sz_path, u16_alt_length ) ) return false; // Error during the read if( 0 != u8_pos_path_in_line ) { // Shift the path to the beginning of the buffer memmove(*sz_path, *sz_path + u8_pos_path_in_line * ((FS_UNICODE==true) ? 2 : 1), (u16_alt_length - u8_pos_path_in_line) * ((FS_UNICODE==true) ? 2 : 1)); } if (opt == PL_MAIN_READLINE_OPT_READSTRING) return true; // Update the navigator with the path of play list file, because the path is relative at this one nav_copy( id_nav ); nav_select( id_nav ); // Go to the path included in the line if( !nav_setcwd( (FS_STRING) *sz_path , false, false ) ) { // path no found then path is dead -> reset list to deselect a file nav_filelist_reset(); } nav_select( FS_NAV_ID_PLAYLIST ); return true; }
//! This function opens the current selected file in the current navigator //! //! @param b_undo true to authorize the undo feature //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool pl_main_open( bool b_undo ) { uint8_t nav_id_save; if( pl_main_isopen() ) return false; // Select the play list file in "play list" navigator nav_id_save = nav_get(); // Save current navigator nav_copy( FS_NAV_ID_PLAYLIST ); nav_select( FS_NAV_ID_PLAYLIST ); // Make sure the selected file is a playlist if( nav_file_checkext("m3u") ) { pl_g_list_type = E_PL_M3U; }else if( nav_file_checkext("pls") ) { pl_g_list_type = E_PL_PLS; }else if( nav_file_checkext("smp") ) { pl_g_list_type = E_PL_SMP; }else goto pl_main_open_end; // Open list #if( PL_READONLY == false ) pl_g_list_undo = b_undo; pl_g_list_is_modify = false; pl_g_list_is_readonly = nav_file_isreadonly(); if( pl_g_list_is_readonly ) { if( !reader_txt_open( true )) goto pl_main_open_end; }else{ if( !reader_txt_open( false )) goto pl_main_open_end; } #else if( !reader_txt_open( true )) goto pl_main_open_end; #endif // Compute the number of file in list pl_g_u16_list_size = 0; while( 0 == file_eof() ) { if( pl_main_readline(PL_MAIN_READLINE_OPT_CHECKLINE,0,NULL,NULL) ) pl_g_u16_list_size++; // Add a file } // Go to at the beginning of text file reader_txt_beg(); pl_g_u16_list_sel = 0; // Don't select a file pl_g_list_is_open = true; // Play list file is opened nav_select( nav_id_save ); // Re select the previous navigator nav_filelist_reset(); pl_main_open_end: nav_select( nav_id_save ); // Re select the previous navigator return pl_g_list_is_open; }
//! This function resets the pointer of selection, so "no file selected" in filtered file list //! //! @return false in case of an error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_filterlist_reset( void ) { fs_g_nav.u16_pos_filterlist = FS_NO_SEL; return nav_filelist_reset(); }