//! This function goes to a position in filtered file list //! //! @param u16_newpos new position to select (0 is the first position) //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_filterlist_goto( uint16_t u16_newpos ) { if (u16_newpos == FS_NO_SEL) return nav_filterlist_reset(); if( u16_newpos < (fs_g_nav.u16_pos_filterlist/2) ) { // Restart at the beginning of list to accelerate search if( !nav_filterlist_reset() ) return false; } if( FS_NO_SEL == fs_g_nav.u16_pos_filterlist ) if( !nav_filterlist_next() ) return false; // No file available while( u16_newpos > fs_g_nav.u16_pos_filterlist ) { if( !nav_filterlist_next() ) break; } while( u16_newpos < fs_g_nav.u16_pos_filterlist ) { if( !nav_filterlist_previous() ) break; } return (u16_newpos == fs_g_nav.u16_pos_filterlist); }
//! This function goes to the next position in the filtered file list //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_filterflat_next( void ) { uint16_t u16_save_current_pos; u16_save_current_pos = nav_filterlist_get(); if( nav_file_isdir() ) { // The current file is a dir then enter in this if( !nav_dir_cd() ) return false; if( nav_filterlist_next() ) { // File present in this dir then valid the new position fs_g_nav.u8_flat_dir_level++; fs_g_nav.u16_flat_pos_offset += u16_save_current_pos+1; return true; }else{ // No file then return in parent dir if( !nav_filterlist_gotoparent() ) return false; } } // Find next file in current dir or parent dir while( !nav_filterlist_next() ) { // End of current directory then goes to parent if( 0 == fs_g_nav.u8_flat_dir_level ) return false; // End of list FLAT if( !nav_filterlist_gotoparent() ) return false; fs_g_nav.u8_flat_dir_level--; } fs_g_nav.u16_flat_pos_offset = (fs_g_nav.u16_flat_pos_offset +u16_save_current_pos +1) -nav_filterlist_get(); return true; }
//! This function selects a file in the navigator via a file index //! //! @param index structure with information about file to select (disk, partition, dir, file/dir selected ) //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! //! @verbatim //! This routine allow to reinit a navigator quickly via a file index (disk, partition, dir, file/dir selected ) //! To get a file index, you shall used the routine nav_getindex(). //! @endverbatim //! bool nav_filterlist_gotoindex( const Fs_index _MEM_TYPE_SLOW_ *index ) { if( !nav_drive_set( index->u8_lun )) return false; #if (FS_MULTI_PARTITION == true) if( !nav_partition_set(index->u8_partition)) return false; #endif if( !nav_partition_mount()) return false; // Initialization of the current entry file with index information fs_g_nav.u32_cluster_sel_dir = index->u32_cluster_sel_dir; // Reset position if ( !nav_filterlist_reset() ) return false; // Research the index in directory while( fs_g_nav_fast.u16_entry_pos_sel_file != index->u16_entry_pos_sel_file ) { if( !nav_filterlist_next() ) { nav_filterlist_reset(); return false; } } return true; }
//! This function goes to at the parent directory //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! //! @verbatim //! After, the filtered file list changes and contains the files and directories of the new directory. //! By default, the file selected in filtered file list is the previous (children) directory. //! @endverbatim //! bool nav_filterlist_gotoparent( void ) { uint32_t u32_cluster_old_dir; if (!fat_check_mount_noopen()) return false; if (0 == fs_g_nav.u32_cluster_sel_dir) { fs_g_status = FS_ERR_IS_ROOT; // There aren't parent return false; } // Select and read information about directory ".." fs_g_nav_fast.u16_entry_pos_sel_file = 1; if ( !fat_read_dir()) return false; fat_get_entry_info(); // Save the children directory cluster u32_cluster_old_dir = fs_g_nav.u32_cluster_sel_dir; // Select the parent directory via information present in the current directory ".." fs_g_nav.u32_cluster_sel_dir = fs_g_nav_entry.u32_cluster; // Select the children directory in new directory (=parent directory) if( false == nav_filterlist_reset()) return false; while( nav_filterlist_next() ) { if (fs_g_nav_entry.u32_cluster == u32_cluster_old_dir) return true; // It is the children directory } fs_g_status = FS_ERR_FS; return false; }
//! This function searches a file name in file list filtered //! //! @param sz_name name to search (UNICODE or ASCII) <br> //! The name must end with NULL or '*' value //! @param b_match_case false to ignore the case //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! //! @verbatim //! This function starts a search at the next position of the current in filtered file list //! @endverbatim //! bool nav_filterlist_findname( const FS_STRING sz_name , bool b_match_case ) { while( 1 ) { if ( !nav_filterlist_next()) return false; if ( nav_file_name( sz_name , 0 , FS_NAME_CHECK , b_match_case )) return true; } }
//! This function goes to the previous position in filtered file list //! //! @return false in case of error, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_filterflat_previous( void ) { uint16_t u16_save_current_pos; u16_save_current_pos = nav_filterlist_get(); if( nav_filterlist_previous() ) { while( 1 ) { if( !nav_file_isdir() ) { fs_g_nav.u16_flat_pos_offset = ((fs_g_nav.u16_flat_pos_offset +u16_save_current_pos) -nav_filterlist_get()) -1; return true; // New position valid } // The file is a dir then enter in this if( !nav_dir_cd() ) return false; if( !nav_filterlist_next() ) { // Dir empty then goes to parent and dir is the new selection nav_filterlist_gotoparent(); fs_g_nav.u16_flat_pos_offset = ((fs_g_nav.u16_flat_pos_offset +u16_save_current_pos) -nav_filterlist_get()) -1; return true; } fs_g_nav.u8_flat_dir_level++; // Go to end of the dir while( nav_filterlist_next() ); } } // Beginning of current directory then goes to parent if( 0 == fs_g_nav.u8_flat_dir_level ) return false; // beginning of list FLAT if( !nav_filterlist_gotoparent() ) return false; fs_g_nav.u8_flat_dir_level--; fs_g_nav.u16_flat_pos_offset -= (nav_filterlist_get()+1); return true; }