This plug-in allow a navigation in filter mode This plug-in is connected on the navigation module. The filter mode includes in the file list directories and only files corresponding at a extension
Definition in file nav_filterlist.c.
#include "conf_explorer.h"
#include "navigation.h"
#include "nav_filterlist.h"
#include "file.h"
#include "ctrl_access.h"
Go to the source code of this file.
Functions | |
Bool | nav_filterlist_cd (void) |
This function enters in the selected directory. | |
Bool | nav_filterlist_findname (const FS_STRING sz_name, Bool b_match_case) |
This function searches a file name in file list filtered. | |
U16 | nav_filterlist_get (void) |
This function returns the position of selected file in filtered file list. | |
Bool | nav_filterlist_goto (U16 u16_newpos) |
This function goes to a position in filtered file list. | |
Bool | nav_filterlist_gotoindex (const Fs_index _MEM_TYPE_SLOW_ *index) |
This function selects a file in the navigator via a file index. | |
Bool | nav_filterlist_gotoparent (void) |
This function goes to at the parent directory. | |
Bool | nav_filterlist_mount (void) |
This function mounts the selected partition. | |
U16 | nav_filterlist_nb (fl_type_t fl_type, const FS_STRING sz_filterext) |
This function computes the number of files and/or directories in filtered file list This function is blocking. | |
Bool | nav_filterlist_nb_ex (fl_type_t fl_type, const FS_STRING sz_filterext, U16 *p_total, U8 retry) |
This function computes the number of files and/or directories in filtered file list This function is not blocking. | |
Bool | nav_filterlist_next (void) |
This function goes to the next position in the filtered file list. | |
Bool | nav_filterlist_previous (void) |
This function goes to the previous position in filtered file list. | |
Bool | nav_filterlist_reset (void) |
This function resets the pointer of selection, so "no file selected" in filtered file list. | |
Bool | nav_filterlist_root (void) |
This function initializes the file filtered list on the root directory. | |
void | nav_filterlist_setfilter (const FS_STRING sz_filterext) |
This function affiliates an extension filter at current navigator. | |
static Bool | update_counter (U8 *counter) |
Update and test the counter. |
Bool nav_filterlist_cd | ( | void | ) |
This function enters in the selected directory.
TRUE otherwise
//! After this routine the file list changes and contains the files and directories of the new directory. //! By default no file is selected. //!
Definition at line 366 of file nav_filterlist.c.
References fs_g_nav, FS_NO_SEL, nav_dir_cd(), and Fs_management::u16_pos_filterlist.
00367 { 00368 fs_g_nav.u16_pos_filterlist = FS_NO_SEL; 00369 return nav_dir_cd(); 00370 }
Bool nav_filterlist_findname | ( | const FS_STRING | sz_name, | |
Bool | b_match_case | |||
) |
This function searches a file name in file list filtered.
sz_name | name to search (UNICODE or ASCII) The name must end with NULL or '*' value | |
b_match_case | FALSE to ignore the case |
TRUE otherwise
//! This function starts a search at the next position of the current in filtered file list //!
Definition at line 193 of file nav_filterlist.c.
References FS_NAME_CHECK, nav_file_name(), and nav_filterlist_next().
00194 { 00195 while( 1 ) 00196 { 00197 if ( !nav_filterlist_next()) 00198 return FALSE; 00199 if ( nav_file_name( sz_name , 0 , FS_NAME_CHECK , b_match_case )) 00200 return TRUE; 00201 } 00202 }
U16 nav_filterlist_get | ( | void | ) |
This function returns the position of selected file in filtered file list.
FS_NO_SEL, in case of no file selected
Definition at line 139 of file nav_filterlist.c.
References fs_g_nav, and Fs_management::u16_pos_filterlist.
Referenced by nav_filterflat_get(), nav_filterflat_next(), and nav_filterflat_previous().
00140 { 00141 return fs_g_nav.u16_pos_filterlist; 00142 }
Bool nav_filterlist_goto | ( | U16 | u16_newpos | ) |
This function goes to a position in filtered file list.
u16_newpos | new position to select (0 is the first position) |
TRUE otherwise
Definition at line 152 of file nav_filterlist.c.
References fs_g_nav, FS_NO_SEL, nav_filterlist_next(), nav_filterlist_previous(), nav_filterlist_reset(), and Fs_management::u16_pos_filterlist.
Referenced by nav_filterlist_nb_ex().
00153 { 00154 if (u16_newpos == FS_NO_SEL) 00155 return nav_filterlist_reset(); 00156 00157 if( u16_newpos < (fs_g_nav.u16_pos_filterlist/2) ) 00158 { 00159 // Restart at the beginning of list to accelerate search 00160 if( !nav_filterlist_reset() ) 00161 return FALSE; 00162 } 00163 if( FS_NO_SEL == fs_g_nav.u16_pos_filterlist ) 00164 if( !nav_filterlist_next() ) 00165 return FALSE; // No file available 00166 while( u16_newpos > fs_g_nav.u16_pos_filterlist ) 00167 { 00168 if( !nav_filterlist_next() ) 00169 break; 00170 } 00171 while( u16_newpos < fs_g_nav.u16_pos_filterlist ) 00172 { 00173 if( !nav_filterlist_previous() ) 00174 break; 00175 } 00176 return (u16_newpos == fs_g_nav.u16_pos_filterlist); 00177 }
Bool nav_filterlist_gotoindex | ( | const Fs_index _MEM_TYPE_SLOW_ * | index | ) |
This function selects a file in the navigator via a file index.
index | structure with information about file to select (disk, partition, dir, file/dir selected ) |
TRUE otherwise
//! 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(). //!
Definition at line 432 of file nav_filterlist.c.
References fs_g_nav, fs_g_nav_fast, nav_drive_set(), nav_filterlist_next(), nav_filterlist_reset(), nav_partition_mount(), nav_partition_set(), Fs_management_fast::u16_entry_pos_sel_file, and Fs_management::u32_cluster_sel_dir.
00433 { 00434 if( !nav_drive_set( index->u8_lun )) 00435 return FALSE; 00436 #if (FS_MULTI_PARTITION == ENABLED) 00437 if( !nav_partition_set(index->u8_partition)) 00438 return FALSE; 00439 #endif 00440 if( !nav_partition_mount()) 00441 return FALSE; 00442 00443 // Initialization of the current entry file with index information 00444 fs_g_nav.u32_cluster_sel_dir = index->u32_cluster_sel_dir; 00445 00446 // Reset position 00447 if ( !nav_filterlist_reset() ) 00448 return FALSE; 00449 00450 // Research the index in directory 00451 while( fs_g_nav_fast.u16_entry_pos_sel_file != index->u16_entry_pos_sel_file ) 00452 { 00453 if( !nav_filterlist_next() ) 00454 { 00455 nav_filterlist_reset(); 00456 return FALSE; 00457 } 00458 } 00459 return TRUE; 00460 }
Bool nav_filterlist_gotoparent | ( | void | ) |
This function goes to at the parent directory.
TRUE otherwise
//! 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. //!
Definition at line 383 of file nav_filterlist.c.
References fat_check_mount_noopen(), fat_get_entry_info(), fat_read_dir(), FS_ERR_FS, FS_ERR_IS_ROOT, fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, fs_g_status, nav_filterlist_next(), nav_filterlist_reset(), Fs_management_fast::u16_entry_pos_sel_file, Fs_management_entry::u32_cluster, and Fs_management::u32_cluster_sel_dir.
Referenced by nav_filterflat_next(), and nav_filterflat_previous().
00384 { 00385 U32 u32_cluster_old_dir; 00386 00387 if (!fat_check_mount_noopen()) 00388 return FALSE; 00389 00390 if (0 == fs_g_nav.u32_cluster_sel_dir) 00391 { 00392 fs_g_status = FS_ERR_IS_ROOT; // There aren't parent 00393 return FALSE; 00394 } 00395 00396 // Select and read information about directory ".." 00397 fs_g_nav_fast.u16_entry_pos_sel_file = 1; 00398 if ( !fat_read_dir()) 00399 return FALSE; 00400 fat_get_entry_info(); 00401 // Save the children directory cluster 00402 u32_cluster_old_dir = fs_g_nav.u32_cluster_sel_dir; 00403 00404 // Select the parent directory via information present in the current directory ".." 00405 fs_g_nav.u32_cluster_sel_dir = fs_g_nav_entry.u32_cluster; 00406 00407 // Select the children directory in new directory (=parent directory) 00408 if( FALSE == nav_filterlist_reset()) 00409 return FALSE; 00410 while( nav_filterlist_next() ) 00411 { 00412 if (fs_g_nav_entry.u32_cluster == u32_cluster_old_dir) 00413 return TRUE; // It is the children directory 00414 } 00415 fs_g_status = FS_ERR_FS; 00416 return FALSE; 00417 }
Bool nav_filterlist_mount | ( | void | ) |
This function mounts the selected partition.
TRUE otherwise
//! If the FS_MULTI_PARTITION option is disabled //! then the mount routine selects the first partition supported by file system. <br> //! After mount, the file list contains files and directories of ROOT directory //!
Definition at line 337 of file nav_filterlist.c.
References fs_g_nav, FS_NO_SEL, nav_partition_mount(), and Fs_management::u16_pos_filterlist.
Referenced by nav_filterflat_mount().
00338 { 00339 fs_g_nav.u16_pos_filterlist = FS_NO_SEL; 00340 return nav_partition_mount(); 00341 }
This function computes the number of files and/or directories in filtered file list This function is blocking.
It will only return when the final count is computed, which may take some time.
fl_type | FL_ALL To check all types (files and directories). FL_DIR To check the directory presence. FL_FILE To check the file presence. | |
sz_filterext | Extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" ). If this argument in NULL, then it uses the defautl filter used by the filterlist. This argument is also ignored for b_type == FS_DIR. |
Definition at line 219 of file nav_filterlist.c.
References nav_filterlist_nb_ex().
00220 { 00221 U16 total=(U16)-1; // Initialization is mandatory 00222 while( !nav_filterlist_nb_ex( fl_type, sz_filterext, &total, 0 ) ); 00223 return total; 00224 }
Bool nav_filterlist_nb_ex | ( | fl_type_t | fl_type, | |
const FS_STRING | sz_filterext, | |||
U16 * | p_total, | |||
U8 | retry | |||
) |
This function computes the number of files and/or directories in filtered file list This function is not blocking.
It will return after <retry> iteration if the result is not yet computed.
fl_type | FL_ALL To check all types (files and directories). FL_DIR To check the directory presence. FL_FILE To check the file presence. | |
sz_filterext | Extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" ). If this argument in NULL, then it uses the defautl filter used by the filterlist. This argument is also ignored for b_type == FS_DIR. | |
p_total | Pointer to the result which will be updated by the function (added). Initialization shall be done before untering into this function. | |
retry | Number of files seen before leaving the function. 0 means that the function is blocking untill the result is known. |
Definition at line 257 of file nav_filterlist.c.
References FL_DIR, FL_FILE, FS_DIR, FS_FILE, FS_FIND_NEXT, fs_g_nav, FS_NO_SEL, nav_file_checkext(), nav_file_isdir(), nav_filelist_set(), nav_filelist_single_disable(), nav_filelist_single_enable(), nav_filterlist_goto(), nav_filterlist_reset(), Fs_management::sz_filterext, Fs_management::u16_pos_filterlist, and update_counter().
Referenced by nav_filterlist_nb().
00258 { 00259 static U16 u16_save_position; 00260 Bool b_is_dir; 00261 00262 // save current position 00263 if( *p_total==(U16) -1 ) 00264 { 00265 u16_save_position = fs_g_nav.u16_pos_filterlist; 00266 00267 // Reset position 00268 if ( !nav_filterlist_reset()) 00269 return TRUE; 00270 00271 if (fl_type == FL_DIR) 00272 nav_filelist_single_enable(FS_DIR); 00273 else if (fl_type == FL_FILE) 00274 nav_filelist_single_enable(FS_FILE); 00275 00276 *p_total = 0; 00277 } 00278 00279 // Scan all 00280 while( nav_filelist_set( 0, FS_FIND_NEXT ) ) 00281 { 00282 b_is_dir = nav_file_isdir(); 00283 00284 // Check if its a file for FL_FILE mode 00285 if (fl_type == FL_FILE && b_is_dir) 00286 { 00287 if (!update_counter(&retry)) 00288 return FALSE; 00289 continue; 00290 } 00291 // Check if its a directory for FL_DIR mode 00292 if (fl_type == FL_DIR && !b_is_dir) 00293 { 00294 if (!update_counter(&retry)) 00295 return FALSE; 00296 continue; 00297 } 00298 // If the selection is on a file 00299 if (!b_is_dir) 00300 { 00301 // Check the extension of the file 00302 if (!((sz_filterext)?nav_file_checkext(sz_filterext):nav_file_checkext(fs_g_nav.sz_filterext))) 00303 if (!update_counter(&retry)) 00304 return FALSE; 00305 } 00306 00307 (*p_total)++; 00308 if (!update_counter(&retry)) 00309 return FALSE; 00310 } 00311 00312 nav_filelist_single_disable(); 00313 00314 // Restore previous position 00315 if ( u16_save_position != FS_NO_SEL ) 00316 { 00317 nav_filterlist_reset(); 00318 }else{ 00319 // After operation, there are a file selected 00320 nav_filterlist_goto( u16_save_position ); 00321 } 00322 return TRUE; 00323 }
Bool nav_filterlist_next | ( | void | ) |
This function goes to the next position in the filtered file list.
TRUE otherwise
Definition at line 88 of file nav_filterlist.c.
References FS_FIND_NEXT, fs_g_nav, FS_NO_SEL, nav_file_checkext(), nav_file_isdir(), nav_filelist_get(), nav_filelist_goto(), nav_filelist_set(), Fs_management::sz_filterext, and Fs_management::u16_pos_filterlist.
Referenced by nav_filterflat_next(), nav_filterflat_previous(), nav_filterlist_findname(), nav_filterlist_goto(), nav_filterlist_gotoindex(), and nav_filterlist_gotoparent().
00089 { 00090 U16 u16_current_pos; 00091 u16_current_pos = nav_filelist_get(); 00092 while( nav_filelist_set( 0, FS_FIND_NEXT ) ) 00093 { 00094 if( nav_file_isdir() 00095 || nav_file_checkext( fs_g_nav.sz_filterext ) ) 00096 { 00097 if( FS_NO_SEL == u16_current_pos ) 00098 { 00099 fs_g_nav.u16_pos_filterlist = 0; 00100 }else{ 00101 fs_g_nav.u16_pos_filterlist++; 00102 } 00103 return TRUE; 00104 } 00105 } 00106 nav_filelist_goto( u16_current_pos ); 00107 return FALSE; 00108 }
Bool nav_filterlist_previous | ( | void | ) |
This function goes to the previous position in filtered file list.
TRUE otherwise
Definition at line 116 of file nav_filterlist.c.
References FS_FIND_PREV, fs_g_nav, nav_file_checkext(), nav_file_isdir(), nav_filelist_get(), nav_filelist_goto(), nav_filelist_set(), Fs_management::sz_filterext, and Fs_management::u16_pos_filterlist.
Referenced by nav_filterflat_previous(), and nav_filterlist_goto().
00117 { 00118 U16 u16_current_pos; 00119 u16_current_pos = nav_filelist_get(); 00120 while( nav_filelist_set( 0, FS_FIND_PREV ) ) 00121 { 00122 if( nav_file_isdir() 00123 || nav_file_checkext( fs_g_nav.sz_filterext ) ) 00124 { 00125 fs_g_nav.u16_pos_filterlist--; 00126 return TRUE; 00127 } 00128 } 00129 nav_filelist_goto( u16_current_pos ); 00130 return FALSE; 00131 }
Bool nav_filterlist_reset | ( | void | ) |
This function resets the pointer of selection, so "no file selected" in filtered file list.
TRUE otherwise
Definition at line 76 of file nav_filterlist.c.
References fs_g_nav, FS_NO_SEL, nav_filelist_reset(), and Fs_management::u16_pos_filterlist.
Referenced by nav_filterflat_gotoparent(), nav_filterflat_reset(), nav_filterlist_goto(), nav_filterlist_gotoindex(), nav_filterlist_gotoparent(), nav_filterlist_nb_ex(), and nav_filterlist_setfilter().
00077 { 00078 fs_g_nav.u16_pos_filterlist = FS_NO_SEL; 00079 return nav_filelist_reset(); 00080 }
Bool nav_filterlist_root | ( | void | ) |
This function initializes the file filtered list on the root directory.
TRUE otherwise
Definition at line 349 of file nav_filterlist.c.
References fs_g_nav, FS_NO_SEL, nav_dir_root(), and Fs_management::u16_pos_filterlist.
Referenced by nav_filterflat_root().
00350 { 00351 fs_g_nav.u16_pos_filterlist = FS_NO_SEL; 00352 return nav_dir_root(); 00353 }
void nav_filterlist_setfilter | ( | const FS_STRING | sz_filterext | ) |
This function affiliates an extension filter at current navigator.
sz_filterext | extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" ) |
Definition at line 64 of file nav_filterlist.c.
References fs_g_nav, nav_filterlist_reset(), and Fs_management::sz_filterext.
00065 { 00066 fs_g_nav.sz_filterext = sz_filterext; 00067 nav_filterlist_reset(); 00068 }
static Bool update_counter | ( | U8 * | counter | ) | [static] |
Update and test the counter.
counter | the counter |
Definition at line 230 of file nav_filterlist.c.
Referenced by nav_filterlist_nb_ex().
00231 { 00232 if (*counter) 00233 (*counter)--; 00234 if (!*counter) 00235 return FALSE; 00236 return TRUE; 00237 }