//! Go to next file or directory 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_next( void ) { uint16_t u16_save_current_pos; u16_save_current_pos = nav_filelist_get(); if( nav_file_isdir() ) { // The current file is a dir then enter in this if( !nav_dir_cd() ) return false; if( nav_filelist_set( 0 , FS_FIND_NEXT ) ) { // A file is 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_dir_gotoparent() ) return false; // Error } } // Find next file in the current dir or the parent dir while( !nav_filelist_set( 0 , FS_FIND_NEXT ) ) { // End of the directory then goes to parent if( 0 == fs_g_nav.u8_flat_dir_level ) return false; // End of list FLAT if( !nav_dir_gotoparent() ) return false; // Error 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_filelist_get(); return true; }
//! Go to previous file or directory 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_previous( void ) { uint16_t u16_save_current_pos; u16_save_current_pos = nav_filelist_get(); if( nav_filelist_set( 0 , FS_FIND_PREV ) ) { 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_filelist_get()) -1; return true; // New valid position } // The selection is a dir then enter in this if( !nav_dir_cd() ) return false; if( !nav_filelist_set( 0 , FS_FIND_NEXT ) ) { // The dir is empty then goes to the parent nav_dir_gotoparent(); // The parent dir is the new selection fs_g_nav.u16_flat_pos_offset = ((fs_g_nav.u16_flat_pos_offset +u16_save_current_pos) -nav_filelist_get()) -1; return true; } fs_g_nav.u8_flat_dir_level++; // Go to the end of dir while( nav_filelist_set( 0 , FS_FIND_NEXT ) ); } } // Beginning of the directory then goes to parent directory if( 0 == fs_g_nav.u8_flat_dir_level ) return false; // beginning of the file list FLAT if( !nav_dir_gotoparent() ) return false; fs_g_nav.u8_flat_dir_level--; fs_g_nav.u16_flat_pos_offset -= (nav_filelist_get()+1); return true; }
//! This function goes to the previous position in filtered file list //! //! @return false in case of an error or no next file, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_filterlist_previous( void ) { uint16_t u16_current_pos; u16_current_pos = nav_filelist_get(); while( nav_filelist_set( 0, FS_FIND_PREV ) ) { if( nav_file_isdir() || nav_file_checkext( fs_g_nav.sz_filterext ) ) { fs_g_nav.u16_pos_filterlist--; return true; } } nav_filelist_goto( u16_current_pos ); return false; }
//! This function goes to the next position in the filtered file list //! //! @return false in case of error or no next file, see global value "fs_g_status" for more detail //! @return true otherwise //! bool nav_filterlist_next( void ) { uint16_t u16_current_pos; u16_current_pos = nav_filelist_get(); while( nav_filelist_set( 0, FS_FIND_NEXT ) ) { if( nav_file_isdir() || nav_file_checkext( fs_g_nav.sz_filterext ) ) { if( FS_NO_SEL == u16_current_pos ) { fs_g_nav.u16_pos_filterlist = 0; }else{ fs_g_nav.u16_pos_filterlist++; } return true; } } nav_filelist_goto( u16_current_pos ); return false; }
//! This function returns the position of selected file in file list FLAT //! //! @return position of selected file (0 is the first position) //! @return FS_NO_SEL, in case of no file selected //! uint16_t nav_flat_get( void ) { return (fs_g_nav.u16_flat_pos_offset + nav_filelist_get()); }