This file defines a useful set of functions for file navigation.
Definition in file navigation.h.
#include "fs_com.h"
#include "fat.h"
Go to the source code of this file.
Defines | |
nav_filelist_set() options parameter | |
#define | FS_FIND_NEXT TRUE |
move in list to next file | |
#define | FS_FIND_PREV FALSE |
move in list to previous file | |
Functions | |
void | nav_checkdisk_disable (void) |
This function disables the disk check before each actions on disk. | |
void | nav_checkdisk_enable (void) |
This function enables the disk check before each actions on disk. | |
Bool | nav_copy (U8 u8_idnav) |
This function copys the navigator information to another navigator. | |
Bool | nav_dir_cd (void) |
This function enters in the selected directory in file list. | |
Bool | nav_dir_gotoparent (void) |
This function goes to the parent directory. | |
Bool | nav_dir_is_root (void) |
This function check the current directory. | |
Bool | nav_dir_make (const FS_STRING sz_name) |
This function creates a directory in the directory corresponding at file list. | |
Bool | nav_dir_name (FS_STRING sz_path, U8 u8_size_max) |
This function returns the directory name corresponding at the file list. | |
Bool | nav_dir_root (void) |
This function initializes the file list on the root directory. | |
Bool | nav_drive_format (U8 u8_fat_type) |
This function formats the current drive (=disk). | |
U8 | nav_drive_get (void) |
This function returns the selected drive number. | |
U8 | nav_drive_getname (void) |
This function returns the selected drive letter. | |
U8 | nav_drive_nb (void) |
This function returns the number of devices availabled. | |
Bool | nav_drive_set (U8 u8_number) |
This function selects a drive in navigator but don't mount the disk partition. | |
void | nav_exit (void) |
This function flush ALL navigations before exit of file system core. | |
U8 | nav_file_attributget (void) |
This function returns the attribut of selected file. | |
Bool | nav_file_attributset (U8 u8_attribut) |
This function changes the attribut of selected file. | |
Bool | nav_file_checkext (const FS_STRING sz_filterext) |
This function checks the extension of selected file. | |
Bool | nav_file_copy (void) |
This function updates the COPY navigator with the selected file. | |
Bool | nav_file_create (const FS_STRING sz_name) |
This function creates a file with NULL size and NULL attribut. | |
Bool | nav_file_dateget (FS_STRING sz_date, Bool type_date) |
This function returns the date of selected file. | |
Bool | nav_file_dateset (const FS_STRING sz_date, Bool type_date) |
This function changes the date of selected file. | |
Bool | nav_file_del (Bool b_only_empty) |
This function deletes the selected file or directory. | |
Bool | nav_file_getname (FS_STRING sz_name, U8 u8_size_max) |
This function returns the name of selected file. | |
Bool | nav_file_isdir (void) |
This function returns the type of selected file. | |
Bool | nav_file_isreadonly (void) |
This function checks the write protection of disk and the attribut "read only" of selected file. | |
U32 | nav_file_lgt (void) |
This function returns the size of selected file (unit byte). | |
U16 | nav_file_lgtsector (void) |
This function returns the size of selected file (unit sector). | |
Bool | nav_file_name (FS_STRING sz_name, U8 u8_size_max, Bool b_mode, Bool b_match_case) |
This function returns the name of selected file or checks the string with the name of selected file. | |
Bool | nav_file_paste_start (const FS_STRING sz_name) |
This function pastes the selected file in COPY navigator in the file list of the current navigator. | |
U8 | nav_file_paste_state (Bool b_stop) |
This function executes the copy file. | |
Bool | nav_file_rename (const FS_STRING sz_name) |
This function renames the selected directory or file. | |
Bool | nav_filelist_bol (void) |
This function checks the beginning of file list. | |
Bool | nav_filelist_eol (void) |
This function checks the end of file list. | |
Bool | nav_filelist_exist (Bool b_type) |
This function checks the presence of files or directories in file list. | |
Bool | nav_filelist_fileisnotopen (void) |
This function checks if no file is open. | |
Bool | nav_filelist_findname (const FS_STRING sz_name, Bool b_match_case) |
This function searchs a file name in file list. | |
Bool | nav_filelist_first (Bool b_type) |
This function goes to at the first file or directory in file list. | |
U16 | nav_filelist_get (void) |
This function returns the position of selected file in file list. | |
Bool | nav_filelist_goto (U16 u16_newpos) |
This function goes at a position in file list. | |
Bool | nav_filelist_last (Bool b_type) |
This function goes to at the last file or directory in file list. | |
U16 | nav_filelist_nb (Bool b_type) |
This function computes the number of files or directories in file list. | |
Bool | nav_filelist_reset (void) |
This function resets the selection pointer, so "no file selected" in file list. | |
Bool | nav_filelist_set (U16 u16_nb, Bool b_direction) |
This function moves the selection pointer in file list. | |
Bool | nav_filelist_single_disable (void) |
To display in File List the directories AND files. | |
Bool | nav_filelist_single_enable (Bool b_type) |
To display in File List only the files OR directories. | |
Bool | nav_filelist_validpos (void) |
This function checks if a file is selected. | |
U8 | nav_get (void) |
This function returns the navigation identifier used. | |
Bool | nav_getcwd (FS_STRING sz_path, U8 u8_size_path, Bool b_view_file_select) |
This function returns the full path of the selection. | |
Fs_index | nav_getindex (void) |
This function returns a small index on the selected file. | |
Bool | nav_gotoindex (const Fs_index _MEM_TYPE_SLOW_ *index) |
This function selects a file in the navigator via a file index. | |
U8 | nav_partition_cluster_size (void) |
This function returns the partition cluster size. | |
U32 | nav_partition_freespace (void) |
This function returns the partition free space. | |
U8 | nav_partition_freespace_percent (void) |
This function returns the partition space free in percent. | |
Bool | nav_partition_label (Bool b_action, FS_STRING sz_label) |
This function reads or writes the label of selected partition. | |
Bool | nav_partition_mount (void) |
This function mounts the selected partition. | |
U8 | nav_partition_nb (void) |
This function returns the number of partitions present on drive. | |
Bool | nav_partition_serialnumber (Bool b_action, U8 _MEM_TYPE_SLOW_ *a_u8_sn) |
This function reads or writes the serial number on the selected partition. | |
Bool | nav_partition_set (U8 partition_number) |
This function selects a partition on drive. | |
U32 | nav_partition_space (void) |
This function returns partition total space. | |
U8 | nav_partition_type (void) |
This function gives the partition type. | |
void | nav_reset (void) |
This function resets ALL navigations to init file system core. | |
Bool | nav_select (U8 u8_idnav) |
This function selects the navigation to use. | |
Bool | nav_setcwd (FS_STRING sz_path, Bool b_match_case, Bool b_create) |
This function selects a disk position via a path. | |
void | nav_string_ascii (void) |
This function selects the ASCII mode for all routines with FS_STRING parameter. | |
void | nav_string_length_disable (void) |
This function deselects the LENGTH string mode for all routines with FS_STRING parameter. | |
void | nav_string_length_enable (void) |
This function selects the LENGTH string mode for all routines with FS_STRING parameter. | |
void | nav_string_unicode (void) |
This function selects the UNICODE mode for all routines with FS_STRING parameter. |
#define FS_FIND_NEXT TRUE |
move in list to next file
Definition at line 51 of file navigation.h.
Referenced by main(), nav_dir_gotoparent(), nav_file_del(), nav_filelist_bol(), nav_filelist_eol(), nav_filelist_exist(), nav_filelist_findname(), nav_filelist_first(), nav_filelist_goto(), nav_filelist_last(), nav_filelist_nb(), nav_filelist_set(), nav_filterlist_nb_ex(), nav_filterlist_next(), nav_flat_next(), nav_flat_previous(), nav_gotoindex(), navauto_mov_explorer(), navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_new_dir(), navauto_mov_explorer_select_limit_dir_cur_folder(), navauto_mov_explorer_select_limit_file_cur_folder(), navauto_mov_ok_loop(), navauto_mov_playlist(), navauto_open(), navauto_setpos(), and pl_add().
#define FS_FIND_PREV FALSE |
move in list to previous file
Definition at line 52 of file navigation.h.
Referenced by nav_filelist_bol(), nav_filelist_eol(), nav_filelist_goto(), nav_filterlist_previous(), nav_flat_previous(), navauto_mov_explorer(), navauto_open(), and navauto_setpos().
void nav_checkdisk_disable | ( | void | ) |
This function disables the disk check before each actions on disk.
//! By default, between each read/write access a check disk (test unit ready) is sended at device. //! This check can reduce the speed access on specific disk. //!
Definition at line 137 of file navigation.c.
References g_b_no_check_disk.
Referenced by reader_txt_get_line().
00138 { 00139 g_b_no_check_disk = TRUE; 00140 }
void nav_checkdisk_enable | ( | void | ) |
This function enables the disk check before each actions on disk.
//! By default, between each read/write access a check disk (test unit ready) is sended at device. //! This check can reduce the speed access on specific disk. //!
Definition at line 149 of file navigation.c.
References g_b_no_check_disk.
Referenced by reader_txt_get_line().
00150 { 00151 g_b_no_check_disk = FALSE; 00152 }
Bool nav_copy | ( | U8 | u8_idnav | ) |
This function copys the navigator information to another navigator.
u8_idnav | navigator identifier where the main navigator will be copied |
TRUE otherwise
//! Use this routine to select quickly the same file in another navigator //!
Definition at line 281 of file navigation.c.
References fat_copy_nav(), and fs_g_u8_nav_selected.
Referenced by nav_file_copy(), pl_main_open(), and pl_main_readline().
00282 { 00283 #if (FS_NB_NAVIGATOR > 1) 00284 if( fs_g_u8_nav_selected == u8_idnav ) 00285 return FALSE; // It is the source and destination is the same navigator 00286 if( 0 == u8_idnav ) 00287 u8_idnav = fs_g_u8_nav_selected; // the default navigator is invert with the current navigator 00288 if( 0 == u8_idnav) 00289 return FALSE; // It is the source and destination is the same navigator 00290 fat_copy_nav( u8_idnav ); 00291 return TRUE; 00292 #else 00293 u8_idnav++; 00294 return FALSE; // Copy impossible because only one navigator is available 00295 #endif 00296 }
Bool nav_dir_cd | ( | void | ) |
This function enters in the selected directory in file list.
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 1189 of file navigation.c.
References fat_check_mount_select_noopen(), fat_entry_is_dir(), fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, nav_filelist_reset(), Fs_management::u16_entry_pos_sel_dir, Fs_management_fast::u16_entry_pos_sel_file, Fs_management_entry::u32_cluster, and Fs_management::u32_cluster_sel_dir.
Referenced by nav_file_del(), nav_filterflat_cd(), nav_filterflat_next(), nav_filterflat_previous(), nav_filterlist_cd(), nav_flat_cd(), nav_flat_next(), nav_flat_previous(), nav_setcwd(), navauto_mov_explorer_is_dir(), navauto_mov_explorer_select_limit_dir_cur_folder(), and pl_add().
01190 { 01191 if ( !fat_check_mount_select_noopen()) 01192 return FALSE; 01193 01194 // The current selection, is it a directory ? 01195 if ( !fat_entry_is_dir()) 01196 return FALSE; 01197 01198 // Select the current directory 01199 fs_g_nav.u16_entry_pos_sel_dir = fs_g_nav_fast.u16_entry_pos_sel_file; 01200 fs_g_nav.u32_cluster_sel_dir = fs_g_nav_entry.u32_cluster; 01201 01202 // Reset file list 01203 if( FALSE == nav_filelist_reset()) 01204 return FALSE; 01205 return TRUE; 01206 }
Bool nav_dir_gotoparent | ( | void | ) |
This function goes to the parent directory.
TRUE otherwise
//! After, the file list changes and contains the files and directories of the new directory. //! By default, the file selected in file list is the previous (children) directory. //!
Definition at line 1219 of file navigation.c.
References Fs_management::b_mode_nav, Fs_management::b_mode_nav_single, fat_check_mount_noopen(), fat_get_entry_info(), fat_read_dir(), FS_DIR, FS_ERR_FS, FS_ERR_IS_ROOT, FS_FIND_NEXT, fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, fs_g_status, nav_filelist_reset(), nav_filelist_set(), Fs_management_fast::u16_entry_pos_sel_file, Fs_management_entry::u32_cluster, and Fs_management::u32_cluster_sel_dir.
Referenced by nav_dir_name(), nav_file_del(), nav_filterflat_gotoparent(), nav_filterflat_reset(), nav_flat_gotoparent(), nav_flat_next(), nav_flat_previous(), nav_flat_reset(), nav_getcwd(), nav_setcwd(), navauto_mov_explorer_updir(), navauto_open(), and pl_add().
01220 { 01221 U32 u32_cluster_old_dir; 01222 01223 if (!fat_check_mount_noopen()) 01224 return FALSE; 01225 01226 if (0 == fs_g_nav.u32_cluster_sel_dir) 01227 { 01228 fs_g_status = FS_ERR_IS_ROOT; // There aren't parent 01229 return FALSE; 01230 } 01231 01232 // Select and read information about directory ".." 01233 fs_g_nav_fast.u16_entry_pos_sel_file = 1; 01234 if ( !fat_read_dir()) 01235 return FALSE; 01236 fat_get_entry_info(); 01237 // Save the children directory cluster 01238 u32_cluster_old_dir = fs_g_nav.u32_cluster_sel_dir; 01239 01240 // Select the parent directory via information present in the current directory ".." 01241 fs_g_nav.u32_cluster_sel_dir = fs_g_nav_entry.u32_cluster; 01242 01243 // Select the children directory in new directory (=parent directory) 01244 if( FALSE == nav_filelist_reset()) 01245 return FALSE; 01246 if( fs_g_nav.b_mode_nav_single && (FS_DIR != fs_g_nav.b_mode_nav) ) 01247 return TRUE; 01248 01249 while( nav_filelist_set( 0 , FS_FIND_NEXT ) ) 01250 { 01251 if (fs_g_nav_entry.u32_cluster == u32_cluster_old_dir) 01252 return TRUE; // It is the children directory 01253 } 01254 fs_g_status = FS_ERR_FS; 01255 return FALSE; 01256 }
Bool nav_dir_is_root | ( | void | ) |
This function check the current directory.
TRUE the current directory selected is the root directory
Definition at line 1170 of file navigation.c.
References fat_check_mount_noopen(), fs_g_nav, and Fs_management::u32_cluster_sel_dir.
01171 { 01172 if (!fat_check_mount_noopen()) 01173 return FALSE; 01174 01175 return (0 == fs_g_nav.u32_cluster_sel_dir); 01176 }
Bool nav_dir_make | ( | const FS_STRING | sz_name | ) |
This function creates a directory in the directory corresponding at file list.
sz_name | directory name (ASCII or UNICODE ) |
TRUE otherwise
Definition at line 1361 of file navigation.c.
References fat_allocfreespace(), fat_cache_flush(), fat_check_mount_noopen(), fat_delete_file(), fat_initialize_dir(), fat_read_dir(), fat_write_entry_file(), FS_ATTR_DIRECTORY, FS_DIR, fs_g_nav_entry, fs_g_seg, nav_file_create(), nav_filelist_last(), Fs_segment::u32_addr, Fs_management_entry::u32_cluster, Fs_management_entry::u32_size, Fs_segment::u32_size_or_pos, and Fs_management_entry::u8_attr.
Referenced by main(), and nav_setcwd().
01362 { 01363 if ( !fat_check_mount_noopen()) 01364 return FALSE; 01365 01366 // Create an entry file 01367 if ( !nav_file_create( sz_name )) 01368 return FALSE; 01369 01370 // Allocate one cluster for the new directory 01371 MSB0(fs_g_seg.u32_addr)=0xFF; // It is a new cluster list 01372 fs_g_seg.u32_size_or_pos = 1; // Only one sector (= one cluster) 01373 if ( !fat_allocfreespace()) 01374 { 01375 fat_delete_file( FALSE ); 01376 fat_cache_flush(); 01377 return FALSE; 01378 } 01379 01380 // Save information about the new directory 01381 fs_g_nav_entry.u32_cluster = fs_g_seg.u32_addr; // First cluster of the directory returned by alloc_free_space 01382 fs_g_nav_entry.u32_size = 0; // The directory size is null 01383 fs_g_nav_entry.u8_attr = FS_ATTR_DIRECTORY; // Directory attribut 01384 01385 // Initialize the values in the new directory 01386 if ( !fat_initialize_dir()) 01387 return FALSE; 01388 01389 // Write directory information in her entry file 01390 if ( !fat_read_dir()) 01391 return FALSE; 01392 fat_write_entry_file(); 01393 if( !fat_cache_flush()) 01394 return FALSE; 01395 01396 // Go to position of new directory (it is the last directory) 01397 return nav_filelist_last( FS_DIR ); 01398 }
Bool nav_dir_name | ( | FS_STRING | sz_path, | |
U8 | u8_size_max | |||
) |
This function returns the directory name corresponding at the file list.
sz_path | string to store the name (ASCII or UNICODE ) | |
u8_size_max | string size (unit ASCII or UNICODE ) |
TRUE otherwise
Definition at line 1267 of file navigation.c.
References Fs_management::b_mode_nav, Fs_management::b_mode_nav_single, fat_check_mount_noopen(), FS_FILE, fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, FS_NAME_GET, g_b_string_length, Is_unicode, nav_dir_gotoparent(), nav_drive_getname(), nav_file_name(), Fs_management::u16_entry_pos_sel_dir, Fs_management_fast::u16_entry_pos_sel_file, Fs_management_entry::u32_cluster, Fs_management::u32_cluster_sel_dir, Fs_management_entry::u32_size, and Fs_management_entry::u8_attr.
Referenced by main().
01268 { 01269 U8 u8_i, u8_character; 01270 Bool status = FALSE; 01271 U16 save_u16_entry_pos_sel_file; 01272 U32 save_u32_cluster_sel_dir; 01273 U8 save_u8_attr ; 01274 U32 save_u32_cluster ; 01275 U32 save_u32_size ; 01276 Bool b_mode_nav_single_save; 01277 Bool b_mode_nav_mode_save; 01278 01279 if ( !fat_check_mount_noopen()) 01280 return FALSE; 01281 01282 if (0 != fs_g_nav.u32_cluster_sel_dir) 01283 { 01284 // Save context 01285 save_u16_entry_pos_sel_file= fs_g_nav_fast.u16_entry_pos_sel_file; 01286 save_u32_cluster_sel_dir = fs_g_nav.u32_cluster_sel_dir ; 01287 save_u8_attr = fs_g_nav_entry.u8_attr ; 01288 save_u32_cluster = fs_g_nav_entry.u32_cluster ; 01289 save_u32_size = fs_g_nav_entry.u32_size ; 01290 b_mode_nav_single_save = fs_g_nav.b_mode_nav_single; 01291 b_mode_nav_mode_save = fs_g_nav.b_mode_nav; 01292 fs_g_nav.b_mode_nav_single = TRUE; 01293 fs_g_nav.b_mode_nav = FS_FILE; 01294 // Go to parent directory and select the children directory 01295 if( !nav_dir_gotoparent() ) 01296 { 01297 fs_g_nav.b_mode_nav_single = b_mode_nav_single_save; 01298 fs_g_nav.b_mode_nav = b_mode_nav_mode_save; 01299 return FALSE; 01300 } 01301 fs_g_nav.b_mode_nav_single = b_mode_nav_single_save ; 01302 fs_g_nav.b_mode_nav = b_mode_nav_mode_save; 01303 // Go to directory name position 01304 fs_g_nav_fast.u16_entry_pos_sel_file = fs_g_nav.u16_entry_pos_sel_dir; 01305 status = nav_file_name( sz_path , u8_size_max , FS_NAME_GET , FALSE ); 01306 // Restore previous context 01307 fs_g_nav_fast.u16_entry_pos_sel_file= save_u16_entry_pos_sel_file; 01308 fs_g_nav.u32_cluster_sel_dir = save_u32_cluster_sel_dir ; 01309 fs_g_nav_entry.u8_attr = save_u8_attr ; 01310 fs_g_nav_entry.u32_cluster = save_u32_cluster ; 01311 fs_g_nav_entry.u32_size = save_u32_size ; 01312 } 01313 else 01314 { 01315 // No parent directory, then it is the root directory 01316 if( g_b_string_length ) 01317 { 01318 ((FS_STR_UNICODE)sz_path )[0] = 3; // 3 chars for path "x:" 01319 status = TRUE; 01320 }else 01321 01322 // Create a device name 01323 for( u8_i = 0 ; u8_i<3 ; u8_i++ ) 01324 { 01325 switch( u8_i ) 01326 { 01327 case 0: 01328 u8_character = nav_drive_getname(); // Letter 01329 break; 01330 case 1: 01331 u8_character = ':'; // ":" 01332 break; 01333 case 2: 01334 default: 01335 u8_character = 0; // end of string 01336 break; 01337 } 01338 if( Is_unicode ) 01339 { 01340 ((FS_STR_UNICODE)sz_path )[0] = u8_character; 01341 }else{ 01342 sz_path [0] = u8_character; 01343 } 01344 sz_path += (Is_unicode? 2 : 1 ); 01345 } 01346 status = TRUE; 01347 01348 } 01349 return status; 01350 }
Bool nav_dir_root | ( | void | ) |
This function initializes the file list on the root directory.
TRUE otherwise
Definition at line 1159 of file navigation.c.
References nav_partition_mount().
Referenced by nav_filterlist_root(), nav_flat_root(), nav_partition_label(), nav_setcwd(), and navauto_mov_explorer_reset().
01160 { 01161 return nav_partition_mount(); 01162 }
Bool nav_drive_format | ( | U8 | u8_fat_type | ) |
This function formats the current drive (=disk).
u8_fat_type | Select the format type FS_FORMAT_DEFAULT, The system chooses the better FAT format FS_FORMAT_FAT, The FAT12 or FAT16 is used to format the drive, if possible (disk space <2GB) FS_FORMAT_FAT32, The FAT32 is used to format the drive, if possible (disk space >32MB) FS_FORMAT_NOMBR_FLAG, if you don't want a MRB on the disk then add this flag (e.g. specific partition structure on a CD support) |
TRUE otherwise
//! WARNING: This routine can't format a multi-partiton, if the disk contains a multi-partition //! then this one is erased and replaced by a single partition on ALL disk space. //!
Definition at line 399 of file navigation.c.
References fat_check_nav_access_disk(), fat_check_noopen(), fat_format(), and fat_mount().
Referenced by main().
00400 { 00401 if ( !fat_check_noopen() ) 00402 return FALSE; 00403 if ( !fat_check_nav_access_disk() ) 00404 return FALSE; 00405 if ( !fat_format( u8_fat_type ) ) 00406 return FALSE; 00407 return fat_mount(); 00408 }
U8 nav_drive_get | ( | void | ) |
This function returns the selected drive number.
0xFF in case of no drive selected
Definition at line 353 of file navigation.c.
References fs_g_nav, Fs_management::u8_lun, and Fs_management::u8_partition.
Referenced by main(), and navauto_mov_ok_loop().
00354 { 00355 #if (FS_MULTI_PARTITION == ENABLED) 00356 if(0xFF == fs_g_nav.u8_lun) 00357 return 0xFF; 00358 return ((fs_g_nav.u8_lun*4) + fs_g_nav.u8_partition); // Maximum 4 partitions per device 00359 #else 00360 return (fs_g_nav.u8_lun); 00361 #endif 00362 }
U8 nav_drive_getname | ( | void | ) |
This function returns the selected drive letter.
'X', in case of no drive selected
Definition at line 370 of file navigation.c.
References fs_g_nav, Fs_management::u8_lun, and Fs_management::u8_partition.
Referenced by nav_dir_name(), and nav_getcwd().
00371 { 00372 if(0xFF == fs_g_nav.u8_lun) 00373 return 'X'; 00374 #if (FS_MULTI_PARTITION == ENABLED) 00375 return ('A' + (fs_g_nav.u8_lun*4) + fs_g_nav.u8_partition); // Maximum 4 partitions per device 00376 #else 00377 return ('A' + fs_g_nav.u8_lun); 00378 #endif 00379 }
U8 nav_drive_nb | ( | void | ) |
This function returns the number of devices availabled.
//! This value may be dynamic because it depends of memory drivers (e.g. Mass Storage disk on USB host mode) //!
Definition at line 311 of file navigation.c.
References get_nb_lun().
Referenced by main(), and navauto_mov_ok_loop().
00312 { 00313 return get_nb_lun(); // Number of devices = Number of lun 00314 }
Bool nav_drive_set | ( | U8 | u8_number | ) |
This function selects a drive in navigator but don't mount the disk partition.
u8_number | device number (0 to nav_drive_nb()-1 ) |
TRUE otherwise
Definition at line 324 of file navigation.c.
References fat_check_noopen(), FS_ERR_END_OF_DRIVE, fs_g_nav, fs_g_nav_fast, fs_g_status, FS_TYPE_FAT_UNM, get_nb_lun(), Fs_management::u8_lun, Fs_management::u8_partition, and Fs_management_fast::u8_type_fat.
Referenced by main(), nav_filterlist_gotoindex(), nav_gotoindex(), nav_setcwd(), navauto_mov_explorer_reset(), and navauto_mov_ok_loop().
00325 { 00326 if ( !fat_check_noopen() ) 00327 return FALSE; 00328 00329 if (u8_number >= get_nb_lun() ) 00330 { 00331 fs_g_status = FS_ERR_END_OF_DRIVE; // The drive number is bad 00332 return FALSE; 00333 } 00334 00335 if ( fs_g_nav.u8_lun == u8_number) 00336 return TRUE; // It is the same drive number 00337 00338 // Go to the device 00339 fs_g_nav.u8_lun = u8_number; 00340 fs_g_nav_fast.u8_type_fat = FS_TYPE_FAT_UNM; 00341 #if (FS_MULTI_PARTITION == ENABLED) 00342 fs_g_nav.u8_partition=0; // by default select the first partition 00343 #endif 00344 return TRUE; 00345 }
void nav_exit | ( | void | ) |
This function flush ALL navigations before exit of file system core.
//! Call this at the program exit or before a USB Device session //!
Definition at line 211 of file navigation.c.
References fat_cache_flush(), file_close(), FS_NB_NAVIGATOR, and nav_select().
00212 { 00213 // If you have opened files then close them 00214 #if (FS_NB_NAVIGATOR > 1) 00215 U8 u8_i; 00216 for( u8_i=0; u8_i<FS_NB_NAVIGATOR; u8_i++) 00217 { 00218 nav_select(u8_i); 00219 file_close(); 00220 } 00221 #else 00222 nav_select(0); 00223 file_close(); 00224 #endif 00225 // Flush data eventually present in FAT cache 00226 fat_cache_flush(); 00227 }
U8 nav_file_attributget | ( | void | ) |
This function returns the attribut of selected file.
Definition at line 1948 of file navigation.c.
References fs_g_nav_entry, and Fs_management_entry::u8_attr.
01949 { 01950 return fs_g_nav_entry.u8_attr; 01951 }
Bool nav_file_attributset | ( | U8 | u8_attribut | ) |
This function changes the attribut of selected file.
u8_attribut | value to write on selected file, see masks "FS_ATTR_" in fs_com.h file. |
TRUE otherwise
Definition at line 1988 of file navigation.c.
References fat_cache_flush(), fat_check_mount_select(), fat_read_dir(), fat_write_entry_file(), FS_ATTR_ARCHIVE, FS_ATTR_HIDDEN, FS_ATTR_READ_ONLY, FS_ATTR_SYSTEM, fs_g_nav_entry, and Fs_management_entry::u8_attr.
01989 { 01990 if ( !fat_check_mount_select()) 01991 return FALSE; 01992 01993 // Read selected entry in directory 01994 if ( !fat_read_dir()) 01995 return FALSE; 01996 01997 // Write the new attribut 01998 fs_g_nav_entry.u8_attr &= (~(FS_ATTR_READ_ONLY|FS_ATTR_HIDDEN|FS_ATTR_SYSTEM|FS_ATTR_ARCHIVE)); 01999 fs_g_nav_entry.u8_attr |= u8_attribut & (FS_ATTR_READ_ONLY|FS_ATTR_HIDDEN|FS_ATTR_SYSTEM|FS_ATTR_ARCHIVE); 02000 fat_write_entry_file(); 02001 return fat_cache_flush(); // To write all data and check write access before exit function 02002 }
Bool nav_file_checkext | ( | const FS_STRING | sz_filterext | ) |
This function checks the extension of selected file.
sz_filterext | extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" ) |
FALSE, in other case
Definition at line 1905 of file navigation.c.
References fat_check_mount_select(), fat_entry_checkext(), and fat_read_dir().
Referenced by nav_filterlist_nb_ex(), nav_filterlist_next(), nav_filterlist_previous(), navauto_mov_explorer_is_file(), navauto_mov_explorer_select_limit_file_cur_folder(), navauto_open(), pl_add(), and pl_main_open().
01906 { 01907 if ( fat_check_mount_select() ) 01908 { 01909 // Read selected entry (=short name entry) in directory 01910 if ( fat_read_dir()) 01911 { 01912 // Check the extension with filter 01913 if ( fat_entry_checkext( (FS_STRING) sz_filterext ) ) 01914 return TRUE; 01915 } 01916 } 01917 return FALSE; 01918 }
Bool nav_file_copy | ( | void | ) |
This function updates the COPY navigator with the selected file.
TRUE otherwise
//! If you use the COPY navigator after this routine then the copy information is lost (see FS_NAV_ID_COPYFILE in conf_explorer.h). //!
Definition at line 2191 of file navigation.c.
References FS_ERR_COPY_DIR, fs_g_status, FS_NAV_ID_COPYFILE, nav_copy(), and nav_file_isdir().
Referenced by main(), and pl_main_modify().
02192 { 02193 if( nav_file_isdir() ) 02194 { 02195 fs_g_status = FS_ERR_COPY_DIR; // Impossible to copy a directory 02196 return FALSE; 02197 } 02198 // In "copy file" navigator select the file 02199 nav_copy( FS_NAV_ID_COPYFILE ); 02200 return TRUE; 02201 }
Bool nav_file_create | ( | const FS_STRING | sz_name | ) |
This function creates a file with NULL size and NULL attribut.
sz_name | file name to create (ASCII or UNICODE ) |
TRUE otherwise
//! If you ues this routine to create a file, then you must called file_open() to open this new file //!
Definition at line 2156 of file navigation.c.
References Fs_management::b_mode_nav, fat_cache_flush(), fat_create_entry_file_name(), FS_ERR_FILE_EXIST, FS_FILE, fs_g_nav, fs_g_nav_entry, fs_g_status, nav_filelist_findname(), nav_filelist_reset(), Fs_management::u16_pos_sel_file, Fs_management_entry::u32_cluster, Fs_management_entry::u32_size, and Fs_management_entry::u8_attr.
Referenced by main(), nav_dir_make(), nav_file_paste_start(), nav_file_rename(), nav_setcwd(), and reader_txt_new().
02157 { 02158 // Check if the name already exists 02159 if (!nav_filelist_reset()) 02160 return FALSE; 02161 if (nav_filelist_findname(sz_name , FALSE)) 02162 { 02163 fs_g_status = FS_ERR_FILE_EXIST; 02164 return FALSE; // File exist -> it is not possible to create this name 02165 } 02166 // FYC: here, the selection is at the end of the list 02167 // Create name entrys 02168 if ( !fat_create_entry_file_name( sz_name )) 02169 return FALSE; // error 02170 // By default the information about the new file is NULL 02171 fs_g_nav_entry.u32_cluster = 0; // No first cluster 02172 fs_g_nav_entry.u32_size = 0; // The size is null 02173 fs_g_nav_entry.u8_attr = 0; // Attribut is a file 02174 02175 // It is the last FILE of the list 02176 fs_g_nav.u16_pos_sel_file++; 02177 fs_g_nav.b_mode_nav = FS_FILE; 02178 return fat_cache_flush(); 02179 }
Bool nav_file_dateget | ( | FS_STRING | sz_date, | |
Bool | type_date | |||
) |
This function returns the date of selected file.
type_date | FS_DATE_LAST_WRITE, to get the date of last write access FS_DATE_CREATION, to get the date of file creation | |
sz_date | ASCCI string (>17B) to store the information about date "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, seconde, miliseconde |
TRUE otherwise
Definition at line 1931 of file navigation.c.
References fat_check_mount_select(), fat_get_date(), and fat_read_dir().
01932 { 01933 if ( !fat_check_mount_select()) 01934 return FALSE; 01935 01936 // Read selected entry in directory 01937 if ( !fat_read_dir()) 01938 return FALSE; 01939 fat_get_date( sz_date , type_date ); 01940 return TRUE; 01941 }
Bool nav_file_dateset | ( | const FS_STRING | sz_date, | |
Bool | type_date | |||
) |
This function changes the date of selected file.
type_date | FS_DATE_LAST_WRITE, to get the date of last write access FS_DATE_CREATION, to get the date of file creation | |
sz_date | ASCCI string contains the date to write "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, seconde, miliseconde |
TRUE otherwise
Definition at line 1966 of file navigation.c.
References fat_cache_flush(), fat_check_mount_select(), fat_read_dir(), and fat_set_date().
01967 { 01968 if ( !fat_check_mount_select()) 01969 return FALSE; 01970 01971 // Read selected entry in directory 01972 if ( !fat_read_dir()) 01973 return FALSE; 01974 fat_set_date( sz_date , type_date ); 01975 return fat_cache_flush(); // To write all data and check write access before exit function 01976 }
Bool nav_file_del | ( | Bool | b_only_empty | ) |
This function deletes the selected file or directory.
b_only_empty | TRUE, delete the directory only if empty FALSE, delete directories and files include in selected directory If the selection is not a directory then this param is ignored. |
TRUE otherwise
Definition at line 2016 of file navigation.c.
References fat_cache_flush(), fat_check_mount_select_noopen(), fat_check_nav_access_file(), fat_delete_file(), FS_ERR_DIR_NOT_EMPTY, FS_FIND_NEXT, fs_g_status, nav_dir_cd(), nav_dir_gotoparent(), nav_file_isdir(), nav_filelist_reset(), and nav_filelist_set().
Referenced by main(), nav_file_paste_state(), pl_main_close(), pl_main_modify(), and pl_main_save().
02017 { 02018 U8 u8_folder_level = 0xFF; 02019 02020 if ( !fat_check_mount_select_noopen()) 02021 return FALSE; 02022 02023 if( 0xFF == u8_folder_level ) // to remove a eventually compile warning 02024 goto nav_file_del_test_dir_or_file; 02025 02026 // loop to scan and delete ALL folders and ALL files 02027 while(1) 02028 { 02029 while(1) 02030 { 02031 if( nav_filelist_set( 0 , FS_FIND_NEXT ) ) 02032 { 02033 // Directory no empty 02034 if( b_only_empty ) 02035 { 02036 fs_g_status = FS_ERR_DIR_NOT_EMPTY; // Erase only the empty directory 02037 return FALSE; 02038 } 02039 break; // Exit loop to delete files or directories present 02040 } 02041 // HERE, directory empty 02042 02043 // Go to parent directory and this one select the children directory 02044 if( !nav_dir_gotoparent() ) 02045 return FALSE; 02046 02047 // Delete children directory name and her cluster list 02048 if ( !fat_delete_file( TRUE )) 02049 return FALSE; 02050 02051 if( 0 == u8_folder_level ) 02052 { 02053 // All directory tree is deleted 02054 return TRUE; //********* END OF DEL TREE ************** 02055 } 02056 u8_folder_level--; 02057 02058 } // end of second while (1) 02059 02060 nav_file_del_test_dir_or_file: 02061 if( nav_file_isdir()) 02062 { 02063 // here, a directory is found and is selected 02064 if( !nav_dir_cd()) 02065 return FALSE; 02066 u8_folder_level++; 02067 } 02068 else 02069 { 02070 // here, a file is found and is selected 02071 if( !fat_check_nav_access_file( TRUE ) ) 02072 return FALSE; 02073 // delete file entry name and cluster list 02074 if ( !fat_delete_file( TRUE )) 02075 return FALSE; 02076 if( 0xFF == u8_folder_level ) 02077 break; // only one file to delete 02078 } // if dir OR file 02079 } // end of first while(1) 02080 02081 // Reset selection 02082 nav_filelist_reset(); 02083 return fat_cache_flush(); // To write all data and check write access before exit function 02084 }
Bool nav_file_getname | ( | FS_STRING | sz_name, | |
U8 | u8_size_max | |||
) |
This function returns the name of selected file.
sz_name | string to store the name file (ASCII or UNICODE ) | |
u8_size_max | string size (unit ASCII or UNICODE ) |
TRUE otherwise
Definition at line 1748 of file navigation.c.
References FS_NAME_GET, and nav_file_name().
01749 { 01750 return nav_file_name( sz_name, u8_size_max, FS_NAME_GET, FALSE ); 01751 }
Bool nav_file_isdir | ( | void | ) |
This function returns the type of selected file.
FALSE, in other case
Definition at line 1892 of file navigation.c.
References fat_entry_is_dir().
Referenced by main(), nav_file_copy(), nav_file_del(), nav_filterflat_next(), nav_filterflat_previous(), nav_filterlist_nb_ex(), nav_filterlist_next(), nav_filterlist_previous(), nav_flat_next(), nav_flat_previous(), navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_rec(), and pl_add().
01893 { 01894 return fat_entry_is_dir(); 01895 }
Bool nav_file_isreadonly | ( | void | ) |
This function checks the write protection of disk and the attribut "read only" of selected file.
TRUE, in other case
Definition at line 1877 of file navigation.c.
References fat_check_mount_select(), FS_ATTR_READ_ONLY, fs_g_nav, fs_g_nav_entry, mem_wr_protect(), Fs_management_entry::u8_attr, and Fs_management::u8_lun.
Referenced by pl_main_open().
01878 { 01879 if( !fat_check_mount_select() ) 01880 return TRUE; // No file selected 01881 if( mem_wr_protect( fs_g_nav.u8_lun ) ) 01882 return TRUE; // Disk protected 01883 return (0!=(FS_ATTR_READ_ONLY & fs_g_nav_entry.u8_attr)); // Check attribut "read only" 01884 }
U32 nav_file_lgt | ( | void | ) |
This function returns the size of selected file (unit byte).
Definition at line 1856 of file navigation.c.
References fs_g_nav_entry, and Fs_management_entry::u32_size.
Referenced by fsaccess_file_get_size(), main(), nav_file_paste_state(), and pl_add().
01857 { 01858 return fs_g_nav_entry.u32_size; 01859 }
U16 nav_file_lgtsector | ( | void | ) |
This function returns the size of selected file (unit sector).
Definition at line 1866 of file navigation.c.
References FS_512B_SHIFT_BIT, fs_g_nav_entry, and Fs_management_entry::u32_size.
Referenced by main().
01867 { 01868 return (fs_g_nav_entry.u32_size >> FS_512B_SHIFT_BIT); 01869 }
Bool nav_file_name | ( | FS_STRING | sz_name, | |
U8 | u8_size_max, | |||
Bool | b_mode, | |||
Bool | b_match_case | |||
) |
This function returns the name of selected file or checks the string with the name of selected file.
b_mode | action mode: FS_NAME_GET to get the name of selected file FS_NAME_CHECK to check the name of selected file | |
sz_name | if FS_NAME_GET then string to store the file name (ASCII or UNICODE ) if FS_NAME_CHECK then string to match with file name (ASCII or UNICODE), it must be terminated by NULL or '*' value | |
b_match_case | FALSE, ignore the case (only used in "FS_NAME_CHECK" action) | |
u8_size_max | string size (unit ASCII or UNICODE ), only used in "FS_NAME_GET" action |
TRUE otherwise
Definition at line 1769 of file navigation.c.
References fat_check_mount_select(), fat_entry_longname(), fat_entry_shortname(), fat_read_dir(), FS_ERR_ENTRY_BAD, fs_g_nav_fast, fs_g_status, FS_NAME_GET, FS_NO_LAST_LFN_ENTRY, FS_SIZE_LFN_ENTRY, g_b_string_length, Is_unicode, and Fs_management_fast::u16_entry_pos_sel_file.
Referenced by main(), nav_dir_name(), nav_file_getname(), nav_filelist_findname(), nav_filterflat_findname(), nav_filterlist_findname(), nav_flat_findname(), nav_getcwd(), and pl_main_close().
01770 { 01771 _MEM_TYPE_SLOW_ U16 u16_lgt; // Only used if LENGTH string mode enabled 01772 U16 u16_ptr_save_entry; 01773 Bool b_readshortname = FALSE; 01774 01775 if ( !fat_check_mount_select()) 01776 return FALSE; 01777 01778 // Check if the string size is not 0 01779 if( (FS_NAME_GET == b_mode) 01780 && (0 == u8_size_max) ) 01781 { 01782 return TRUE; 01783 } 01784 01785 // Save the current entry position 01786 u16_ptr_save_entry = fs_g_nav_fast.u16_entry_pos_sel_file; 01787 // if it is the beginning of the directory 01788 if ( 0 == fs_g_nav_fast.u16_entry_pos_sel_file ) 01789 { 01790 b_readshortname = TRUE; // It isn't possibled to have a long name 01791 } 01792 else 01793 { 01794 fs_g_nav_fast.u16_entry_pos_sel_file--; // Initialize entry position to search the first long name entry 01795 } 01796 01797 // Loop in directory entry 01798 u16_lgt = 0; 01799 while( 1 ) 01800 { 01801 if ( !fat_read_dir()) 01802 break; // error 01803 01804 if ( b_readshortname ) 01805 { 01806 // No long name present then read short name 01807 return fat_entry_shortname( sz_name , u8_size_max , b_mode ); 01808 } 01809 01810 // Check or read the part of long file name in this entry 01811 if ( fat_entry_longname( sz_name , u8_size_max , b_mode , b_match_case )) 01812 { 01813 if( g_b_string_length ) 01814 { 01815 ((FS_STR_UNICODE)sz_name )[0] += u16_lgt; 01816 } 01817 fs_g_nav_fast.u16_entry_pos_sel_file = u16_ptr_save_entry; 01818 return TRUE; 01819 } 01820 01821 if ( FS_NO_LAST_LFN_ENTRY != fs_g_status ) 01822 { 01823 // Go to the main entry file (=short name entry) 01824 fs_g_nav_fast.u16_entry_pos_sel_file = u16_ptr_save_entry; 01825 01826 if ( FS_ERR_ENTRY_BAD == fs_g_status ) 01827 { 01828 // It isn't a long name entry then there aren't long file name 01829 b_readshortname = TRUE; // It is mandatory to use the short name 01830 continue; // restart the loop 01831 } 01832 // here, it is a error system or the string don't match with the file name 01833 break; 01834 } 01835 if( g_b_string_length ) 01836 { 01837 u16_lgt += FS_SIZE_LFN_ENTRY; 01838 } 01839 else 01840 { 01841 // Increment the string to store the next part of file name 01842 sz_name += FS_SIZE_LFN_ENTRY * (Is_unicode? 2 : 1 ); 01843 u8_size_max -= FS_SIZE_LFN_ENTRY; 01844 } 01845 fs_g_nav_fast.u16_entry_pos_sel_file--; // Go to the next part of long file name 01846 01847 } // end of loop while(1) 01848 return FALSE; 01849 }
Bool nav_file_paste_start | ( | const FS_STRING | sz_name | ) |
This function pastes the selected file in COPY navigator in the file list of the current navigator.
sz_name | file name of the new file (ASCII or UNICODE ) |
TRUE otherwise
//! After this routine, you shall called nav_file_paste_state() to run and way the copy //!
Definition at line 2215 of file navigation.c.
References file_close(), file_open(), FOPEN_MODE_R, FOPEN_MODE_W_PLUS, FS_ERR_COPY_RUNNING, fs_g_status, FS_NAV_ID_COPYFILE, g_id_trans_memtomem, g_segment_src, ID_STREAM_ERR, nav_file_create(), nav_get(), nav_select(), and Fs_file_segment::u16_size.
Referenced by main(), and pl_main_modify().
02216 { 02217 U8 nav_id_save; 02218 Bool status; 02219 02220 if( ID_STREAM_ERR != g_id_trans_memtomem ) 02221 { 02222 02223 fs_g_status = FS_ERR_COPY_RUNNING; // A copy action is always running 02224 return FALSE; 02225 } 02226 02227 // Create the file to paste 02228 if( !nav_file_create( sz_name ) ) 02229 return FALSE; 02230 // Open the file in write mode with size 0 02231 if( !file_open( FOPEN_MODE_W_PLUS )) 02232 return FALSE; 02233 02234 // Open the file to copy 02235 nav_id_save = nav_get(); 02236 nav_select( FS_NAV_ID_COPYFILE ); 02237 status = file_open(FOPEN_MODE_R); 02238 nav_select( nav_id_save ); 02239 02240 // If error then close "paste file" 02241 if( !status ) 02242 { 02243 file_close(); 02244 return FALSE; 02245 }else{ 02246 // Signal start copy 02247 g_id_trans_memtomem = ID_STREAM_ERR-1; 02248 g_segment_src.u16_size = 0; 02249 return TRUE; 02250 } 02251 }
U8 nav_file_paste_state | ( | Bool | b_stop | ) |
This function executes the copy file.
b_stop | set TRUE to stop copy action |
Definition at line 2263 of file navigation.c.
References COPY_BUSY, COPY_FAIL, COPY_FINISH, CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, file_close(), file_eof(), file_read(), file_seek(), file_set_eof(), file_write(), FS_512B, FS_NAV_ID_COPYFILE, FS_SEEK_CUR_RE, FS_SEEK_SET, g_id_trans_memtomem, g_segment_dest, g_segment_src, ID_STREAM_ERR, nav_file_del(), nav_file_lgt(), nav_get(), nav_select(), SIZE_OF_SPLIT_COPY, stream_mem_to_mem(), stream_state(), stream_stop(), Fs_file_segment::u16_size, Fs_file_segment::u32_addr, and Fs_file_segment::u8_lun.
Referenced by main(), and pl_main_modify().
02264 { 02265 Ctrl_status status_stream; 02266 U8 status_copy; 02267 U8 nav_id_save; 02268 _MEM_TYPE_SLOW_ U16 u16_nb_sector_trans; 02269 02270 nav_id_save = nav_get(); 02271 02272 // Check, if the copy is running 02273 if( ID_STREAM_ERR == g_id_trans_memtomem ) 02274 return COPY_FAIL; 02275 02276 if( b_stop ) 02277 { 02278 status_copy = COPY_FAIL; 02279 } 02280 else 02281 { 02282 if( (ID_STREAM_ERR-1) != g_id_trans_memtomem ) 02283 { 02284 // It isn't the beginning of copy action, then check current stream 02285 status_stream = stream_state( g_id_trans_memtomem ); 02286 switch( status_stream ) 02287 { 02288 case CTRL_BUSY: 02289 status_copy = COPY_BUSY; 02290 break; 02291 case CTRL_GOOD: 02292 status_copy = COPY_FINISH; 02293 break; 02294 case CTRL_FAIL: 02295 default: 02296 status_copy = COPY_FAIL; 02297 break; 02298 } 02299 }else{ 02300 status_copy = COPY_FINISH; 02301 } 02302 02303 // Compute the new segment to copy 02304 if( COPY_FINISH == status_copy ) 02305 { 02306 stream_stop( g_id_trans_memtomem ); 02307 02308 if( 0 != g_segment_src.u16_size ) 02309 { 02310 status_copy = COPY_BUSY; // start the next continue stream 02311 } 02312 else 02313 { 02314 // check eof source file 02315 nav_select( FS_NAV_ID_COPYFILE ); 02316 if( 0 == file_eof() ) 02317 { 02318 status_copy = COPY_BUSY; 02319 g_segment_src.u16_size = 0xFFFF; // Get the maximum segment supported by navigation (U16) 02320 if( !file_read( &g_segment_src )) 02321 { 02322 status_copy = COPY_FAIL; 02323 } 02324 } 02325 nav_select( nav_id_save ); 02326 02327 // Check destination file 02328 if( COPY_BUSY == status_copy ) 02329 { 02330 g_segment_dest.u16_size = g_segment_src.u16_size; // Ask the segment no more larger than source segment 02331 if( !file_write( &g_segment_dest )) 02332 { 02333 status_copy = COPY_FAIL; 02334 } 02335 } 02336 02337 // Start new segment copy 02338 if( COPY_BUSY == status_copy ) 02339 { 02340 // Compute a minimal segment 02341 if( g_segment_src.u16_size > g_segment_dest.u16_size ) 02342 { 02343 // Reposition source file 02344 nav_select( FS_NAV_ID_COPYFILE ); 02345 if( !file_seek( (U32)(g_segment_src.u16_size - g_segment_dest.u16_size)*FS_512B , FS_SEEK_CUR_RE )) 02346 { 02347 status_copy = COPY_FAIL; 02348 } 02349 nav_select( nav_id_save ); 02350 g_segment_src.u16_size = g_segment_dest.u16_size; // Update source to start a correct transfer 02351 } 02352 } 02353 } 02354 if( COPY_BUSY == status_copy ) 02355 { 02356 // Split transfer by step of SIZE_OF_SPLIT_COPY 02357 if( g_segment_src.u16_size < SIZE_OF_SPLIT_COPY ) 02358 u16_nb_sector_trans = g_segment_src.u16_size; 02359 else 02360 u16_nb_sector_trans = SIZE_OF_SPLIT_COPY; 02361 02362 g_id_trans_memtomem = stream_mem_to_mem( g_segment_src.u8_lun , g_segment_src.u32_addr , g_segment_dest.u8_lun , g_segment_dest.u32_addr , u16_nb_sector_trans ); 02363 if( ID_STREAM_ERR == g_id_trans_memtomem ) 02364 status_copy = COPY_FAIL; 02365 g_segment_src.u32_addr +=u16_nb_sector_trans; 02366 g_segment_dest.u32_addr+=u16_nb_sector_trans; 02367 g_segment_src.u16_size -=u16_nb_sector_trans; 02368 } 02369 } 02370 } 02371 02372 // Check end of copy 02373 if( COPY_BUSY != status_copy ) 02374 { 02375 U32 u32_size_exact; 02376 02377 // Stop copy 02378 stream_stop( g_id_trans_memtomem ); 02379 g_id_trans_memtomem = ID_STREAM_ERR; 02380 02381 // Get exact size and close the source file 02382 nav_select( FS_NAV_ID_COPYFILE ); 02383 u32_size_exact = nav_file_lgt(); 02384 file_close(); 02385 nav_select( nav_id_save ); 02386 02387 // If no error then set the exact size on the destination file 02388 if( COPY_FINISH == status_copy ) 02389 { 02390 if( !file_seek( u32_size_exact , FS_SEEK_SET )) 02391 { 02392 status_copy = COPY_FAIL; 02393 }else{ 02394 if( !file_set_eof() ) 02395 { 02396 status_copy = COPY_FAIL; 02397 } 02398 } 02399 } 02400 file_close(); 02401 // If error then delete the destination file 02402 if( COPY_FAIL == status_copy ) 02403 { 02404 nav_file_del( TRUE ); 02405 } 02406 } 02407 return status_copy; 02408 }
Bool nav_file_rename | ( | const FS_STRING | sz_name | ) |
This function renames the selected directory or file.
sz_name | new name (ASCII or UNICODE ) |
TRUE otherwise
Definition at line 2096 of file navigation.c.
References Fs_management::b_mode_nav, fat_cache_flush(), fat_check_mount_select_noopen(), fat_check_nav_access_file(), fat_delete_file(), fat_read_dir(), fat_write_entry_file(), fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, nav_file_create(), nav_filelist_last(), Fs_management_fast::u16_entry_pos_sel_file, Fs_management_entry::u32_cluster, Fs_management_entry::u32_size, and Fs_management_entry::u8_attr.
Referenced by main(), and pl_main_close().
02097 { 02098 U16 u16_save_entry_pos; 02099 Bool b_save_entry_type; 02100 U8 u8_attr; 02101 U32 u32_cluster; 02102 U32 u32_size; 02103 02104 if ( !fat_check_mount_select_noopen()) 02105 return FALSE; 02106 02107 if( !fat_check_nav_access_file( TRUE ) ) 02108 return FALSE; 02109 02110 // Note: in case of error, create the new name before delete the current name 02111 02112 // Save information about current name poisition 02113 u16_save_entry_pos = fs_g_nav_fast.u16_entry_pos_sel_file; 02114 b_save_entry_type = fs_g_nav.b_mode_nav; 02115 // Save information about file 02116 u8_attr = fs_g_nav_entry.u8_attr; 02117 u32_cluster = fs_g_nav_entry.u32_cluster; 02118 u32_size = fs_g_nav_entry.u32_size; 02119 02120 // Create a name 02121 if ( !nav_file_create( sz_name )) 02122 return FALSE; // error 02123 // Restore information about file or directory on the new name entry 02124 if ( !fat_read_dir()) 02125 return FALSE; 02126 fs_g_nav_entry.u8_attr = u8_attr; 02127 fs_g_nav_entry.u32_cluster = u32_cluster; 02128 fs_g_nav_entry.u32_size = u32_size; 02129 fat_write_entry_file(); 02130 02131 // Delete old entry name 02132 fs_g_nav_fast.u16_entry_pos_sel_file = u16_save_entry_pos; // go to old entry name 02133 if ( !fat_delete_file(FALSE) ) 02134 return FALSE; 02135 if ( !fat_cache_flush() ) 02136 return FALSE; 02137 02138 // Go to at the position of the new name entry (it is the last file or directory ) 02139 return nav_filelist_last( b_save_entry_type ); 02140 }
Bool nav_filelist_bol | ( | void | ) |
This function checks the beginning of file list.
TRUE, in case of the file selected is the first file, or in case of error
Definition at line 947 of file navigation.c.
References FS_FIND_NEXT, FS_FIND_PREV, and nav_filelist_set().
00948 { 00949 if( FALSE == nav_filelist_set( 0 , FS_FIND_PREV ) ) 00950 return TRUE; // End of list or error (remark: the position haven't changed) 00951 // Go to previous position 00952 nav_filelist_set( 0 , FS_FIND_NEXT ); 00953 return FALSE; 00954 }
Bool nav_filelist_eol | ( | void | ) |
This function checks the end of file list.
TRUE, in case of end of list or error
Definition at line 923 of file navigation.c.
References Fs_management::b_mode_nav, FS_DIR, FS_FIND_NEXT, FS_FIND_PREV, fs_g_nav, fs_g_nav_fast, FS_NO_SEL, nav_filelist_set(), Fs_management_fast::u16_entry_pos_sel_file, and Fs_management::u16_pos_sel_file.
00924 { 00925 if( FALSE == nav_filelist_set( 0 , FS_FIND_NEXT ) ) 00926 return TRUE; // End of list or error (remark: the position haven't changed) 00927 00928 if( 0 != fs_g_nav.u16_pos_sel_file ) 00929 { 00930 // Go to previous position 00931 nav_filelist_set( 0 , FS_FIND_PREV ); 00932 }else{ 00933 // No select file before, then reset position 00934 fs_g_nav_fast.u16_entry_pos_sel_file= FS_NO_SEL; 00935 fs_g_nav.u16_pos_sel_file = FS_NO_SEL; 00936 fs_g_nav.b_mode_nav = FS_DIR; 00937 } 00938 return FALSE; 00939 }
Bool nav_filelist_exist | ( | Bool | b_type | ) |
This function checks the presence of files or directories in file list.
b_type | FS_DIR to check the directory presence FS_FILE to check the file presence |
FALSE, in case of no file or no directory exists, or error
Definition at line 965 of file navigation.c.
References FS_FIND_NEXT, fs_g_nav, FS_NO_SEL, nav_filelist_first(), nav_filelist_reset(), nav_filelist_set(), and Fs_management::u16_pos_sel_file.
00966 { 00967 Bool status; 00968 U16 u16_save_position; 00969 00970 // Save current position 00971 u16_save_position = fs_g_nav.u16_pos_sel_file; 00972 // Go to first file or directory 00973 status = nav_filelist_first( b_type ); 00974 // Restore previous position 00975 nav_filelist_reset(); 00976 if ( u16_save_position != FS_NO_SEL ) 00977 { 00978 nav_filelist_set( u16_save_position , FS_FIND_NEXT ); 00979 } 00980 return status; 00981 }
Bool nav_filelist_fileisnotopen | ( | void | ) |
This function checks if no file is open.
FALSE if a file is open
Definition at line 703 of file navigation.c.
References fat_check_noopen().
Referenced by nav_flat_fileisnotopen().
00704 { 00705 return fat_check_noopen(); 00706 }
Bool nav_filelist_findname | ( | const FS_STRING | sz_name, | |
Bool | b_match_case | |||
) |
This function searchs a file name in file list.
sz_name | name to search (UNICODE or ASCII) It must be terminate by 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 file list //!
sz_name | name to search (UNICODE or ASCII) It must be terminate by 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 file list //!
Definition at line 906 of file navigation.c.
References FS_FIND_NEXT, FS_NAME_CHECK, nav_file_name(), and nav_filelist_set().
Referenced by nav_file_create(), and nav_setcwd().
00907 { 00908 while( 1 ) 00909 { 00910 if ( !nav_filelist_set( 0, FS_FIND_NEXT )) 00911 return FALSE; 00912 if ( nav_file_name( sz_name , 0 , FS_NAME_CHECK , b_match_case )) 00913 return TRUE; 00914 } 00915 }
Bool nav_filelist_first | ( | Bool | b_type | ) |
This function goes to at the first file or directory in file list.
b_type | FS_DIR to go at the first directory FS_FILE to go at the first file |
TRUE otherwise
Definition at line 1034 of file navigation.c.
References Fs_management::b_mode_nav, FS_ERR_NO_FIND, FS_FIND_NEXT, fs_g_nav, fs_g_status, nav_filelist_reset(), and nav_filelist_set().
Referenced by main(), nav_filelist_exist(), nav_filelist_last(), navauto_mov_explorer_select_limit_dir_cur_folder(), and navauto_mov_explorer_select_limit_file_cur_folder().
01035 { 01036 // Reset position 01037 if ( !nav_filelist_reset()) 01038 return FALSE; 01039 // Find the first file or directory 01040 while( nav_filelist_set( 0 , FS_FIND_NEXT ) ) 01041 { 01042 if( b_type == fs_g_nav.b_mode_nav ) 01043 return TRUE; // First file or directory found 01044 } 01045 fs_g_status = FS_ERR_NO_FIND; 01046 return FALSE; 01047 }
U16 nav_filelist_get | ( | void | ) |
This function returns the position of selected file in file list.
FS_NO_SEL, in case of no file selected
Definition at line 846 of file navigation.c.
References fs_g_nav, and Fs_management::u16_pos_sel_file.
Referenced by nav_filelist_goto(), nav_filterlist_next(), nav_filterlist_previous(), nav_flat_get(), nav_flat_next(), and nav_flat_previous().
00847 { 00848 return fs_g_nav.u16_pos_sel_file; 00849 }
Bool nav_filelist_goto | ( | U16 | u16_newpos | ) |
This function goes at a position in file list.
u16_newpos | new position to select (0 is the first position) |
TRUE otherwise
Definition at line 859 of file navigation.c.
References FS_FIND_NEXT, FS_FIND_PREV, FS_NO_SEL, nav_filelist_get(), nav_filelist_reset(), and nav_filelist_set().
Referenced by nav_filterlist_next(), and nav_filterlist_previous().
00860 { 00861 U16 u16_current_pos; 00862 00863 if( FS_NO_SEL == u16_newpos ) 00864 return nav_filelist_reset(); 00865 00866 u16_current_pos = nav_filelist_get(); 00867 if( u16_newpos < (u16_current_pos/2) ) 00868 { 00869 // Restart at the beginning of list to accelerate the search 00870 if( !nav_filelist_reset() ) 00871 return FALSE; 00872 u16_current_pos = FS_NO_SEL; 00873 } 00874 if (FS_NO_SEL == u16_current_pos) 00875 { 00876 return nav_filelist_set( u16_newpos, FS_FIND_NEXT ); 00877 } 00878 else 00879 { 00880 if (u16_newpos < u16_current_pos) 00881 { 00882 return nav_filelist_set( u16_current_pos -u16_newpos -1 , FS_FIND_PREV ); 00883 } 00884 if (u16_newpos > u16_current_pos) 00885 { 00886 return nav_filelist_set( u16_newpos -u16_current_pos - 1 , FS_FIND_NEXT ); 00887 } 00888 } 00889 return TRUE; 00890 }
Bool nav_filelist_last | ( | Bool | b_type | ) |
This function goes to at the last file or directory in file list.
b_type | FS_DIR to go at the last directory FS_FILE to go at the last file |
TRUE otherwise
Definition at line 1058 of file navigation.c.
References FS_ERR_NO_FIND, FS_FIND_NEXT, fs_g_status, nav_filelist_first(), nav_filelist_nb(), and nav_filelist_set().
Referenced by nav_dir_make(), nav_file_rename(), navauto_mov_explorer_select_limit_dir_cur_folder(), and navauto_mov_explorer_select_limit_file_cur_folder().
01059 { 01060 U16 u16_nb; 01061 01062 // Get number of file or directory 01063 u16_nb = nav_filelist_nb( b_type ); 01064 if( 0 == u16_nb ) 01065 { 01066 fs_g_status = FS_ERR_NO_FIND; 01067 return FALSE; // NO FILE FOUND 01068 } 01069 // Go to the first file or directory 01070 if ( !nav_filelist_first( b_type )) 01071 return FALSE; 01072 // If there are more one file or directory, then go to at the last of list 01073 if( 1 == u16_nb ) 01074 return TRUE; 01075 u16_nb -= 2; 01076 return nav_filelist_set( u16_nb , FS_FIND_NEXT ); 01077 }
U16 nav_filelist_nb | ( | Bool | b_type | ) |
This function computes the number of files or directories in file list.
b_type | FS_DIR to compute the number of directories FS_FILE to compute the number of files |
Definition at line 991 of file navigation.c.
References Fs_management::b_mode_nav, FS_FILE, FS_FIND_NEXT, fs_g_nav, FS_NO_SEL, nav_filelist_reset(), nav_filelist_set(), and Fs_management::u16_pos_sel_file.
Referenced by main(), nav_filelist_last(), and navauto_mov_explorer().
00992 { 00993 U16 u16_save_position; 00994 U16 u16_save_number_dir; 00995 U16 u16_save_number_file; 00996 00997 // Save current position 00998 u16_save_position = fs_g_nav.u16_pos_sel_file; 00999 // Reset position 01000 if ( !nav_filelist_reset()) 01001 return 0; 01002 // Scan all directory 01003 u16_save_number_dir = 0; 01004 u16_save_number_file = 0; 01005 while( nav_filelist_set( 0 , FS_FIND_NEXT ) ) 01006 { 01007 if( FS_FILE == fs_g_nav.b_mode_nav ) 01008 u16_save_number_file++; // It is a file 01009 else 01010 u16_save_number_dir++; // It is a directory 01011 } 01012 // Restore previous position 01013 nav_filelist_reset(); 01014 if ( u16_save_position != FS_NO_SEL ) 01015 { 01016 nav_filelist_set( u16_save_position , FS_FIND_NEXT ); 01017 } 01018 // Return the value asked 01019 if( FS_FILE == b_type ) 01020 return u16_save_number_file; 01021 else 01022 return u16_save_number_dir; 01023 }
Bool nav_filelist_reset | ( | void | ) |
This function resets the selection pointer, so "no file selected" in file list.
TRUE otherwise
Definition at line 676 of file navigation.c.
References fat_check_mount_noopen(), and fat_clear_entry_info_and_ptr().
Referenced by main(), nav_dir_cd(), nav_dir_gotoparent(), nav_file_create(), nav_file_del(), nav_filelist_exist(), nav_filelist_first(), nav_filelist_goto(), nav_filelist_nb(), nav_filelist_single_disable(), nav_filelist_single_enable(), nav_filterlist_reset(), nav_flat_gotoparent(), nav_flat_reset(), nav_gotoindex(), nav_setcwd(), navauto_mov_explorer_limit(), navauto_open(), pl_add(), pl_main_open(), pl_main_readline(), and pl_nav_setpos().
00677 { 00678 if ( !fat_check_mount_noopen()) 00679 return FALSE; 00680 00681 // No file selected and reset navigation 00682 fat_clear_entry_info_and_ptr(); 00683 return TRUE; 00684 }
Bool nav_filelist_set | ( | U16 | u16_nb, | |
Bool | b_direction | |||
) |
This function moves the selection pointer in file list.
u16_nb | numbers of file to jump before stopping action 0, stop at the first file found 1, stop at the second file found | |
b_direction | search direction FS_FIND_NEXT, move to next file or directory FS_FIND_PREV, move to previous file or directory |
TRUE otherwise
//! Note: if no file is selected then nav_filelist_set( 0 , FS_NEXT ) goes to the first entry of the file list. //!
Definition at line 726 of file navigation.c.
References Fs_management::b_mode_nav, Fs_management::b_mode_nav_single, fat_check_mount_noopen(), fat_entry_check(), fat_get_entry_info(), fat_read_dir(), FS_DIR, FS_END_FIND, FS_ERR_ENTRY_EMPTY, FS_ERR_FS, FS_ERR_NO_FIND, FS_ERR_OUT_LIST, FS_FILE, FS_FIND_NEXT, fs_g_nav, fs_g_nav_fast, fs_g_status, FS_NO_SEL, Fs_management_fast::u16_entry_pos_sel_file, and Fs_management::u16_pos_sel_file.
Referenced by main(), nav_dir_gotoparent(), nav_file_del(), nav_filelist_bol(), nav_filelist_eol(), nav_filelist_exist(), nav_filelist_findname(), nav_filelist_first(), nav_filelist_goto(), nav_filelist_last(), nav_filelist_nb(), nav_filterlist_nb_ex(), nav_filterlist_next(), nav_filterlist_previous(), nav_flat_next(), nav_flat_previous(), nav_gotoindex(), navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_select_limit_file_cur_folder(), navauto_open(), and pl_add().
00727 { 00728 U16 u16_ptr_save_entry; 00729 U16 u16_save_pos_sel_file; 00730 Bool b_save_entry_type; 00731 Bool b_find_last_entry = FALSE; 00732 00733 if ( !fat_check_mount_noopen()) 00734 return FALSE; 00735 00736 // Save the current selection 00737 u16_ptr_save_entry = fs_g_nav_fast.u16_entry_pos_sel_file; 00738 u16_save_pos_sel_file = fs_g_nav.u16_pos_sel_file; 00739 b_save_entry_type = fs_g_nav.b_mode_nav; 00740 00741 // Loop in directory 00742 while( 1 ) 00743 { 00744 if(( FS_FIND_NEXT == b_direction ) 00745 || ( b_find_last_entry ) ) 00746 { 00747 if ( FS_END_FIND == fs_g_nav_fast.u16_entry_pos_sel_file ) 00748 { 00749 // Too many files in directory (case impossible) 00750 fs_g_status = FS_ERR_FS; 00751 break; 00752 } 00753 fs_g_nav_fast.u16_entry_pos_sel_file++; // Update entry position 00754 } 00755 else 00756 { 00757 if ( FS_NO_SEL == fs_g_nav_fast.u16_entry_pos_sel_file ) 00758 { 00759 // No selected file then previous action impossible 00760 fs_g_status = FS_ERR_NO_FIND; 00761 break; 00762 } 00763 if ( 0 == fs_g_nav_fast.u16_entry_pos_sel_file ) 00764 { 00765 // beginning of directory 00766 if ( (FS_DIR == fs_g_nav.b_mode_nav ) || fs_g_nav.b_mode_nav_single ) 00767 { 00768 // End of directory scan, then no previous action possible 00769 fs_g_status = FS_ERR_NO_FIND; 00770 break; 00771 } 00772 // End of file scan, then find last directory 00773 b_find_last_entry = TRUE; 00774 }else{ 00775 fs_g_nav_fast.u16_entry_pos_sel_file--; // Update entry position 00776 } 00777 } 00778 00779 if( !fat_read_dir()) 00780 { 00781 if( FS_ERR_OUT_LIST != fs_g_status ) 00782 break; // Error 00783 }else{ 00784 if ( fat_entry_check( fs_g_nav.b_mode_nav ) ) 00785 { 00786 // HERE, the file entry match with the type seached 00787 00788 if( b_find_last_entry ) 00789 continue; // The search of last directory is on going then continue the search 00790 00791 // Update position in directory 00792 if ( FS_FIND_NEXT == b_direction ) 00793 fs_g_nav.u16_pos_sel_file++; 00794 else 00795 fs_g_nav.u16_pos_sel_file--; 00796 00797 if (0 == u16_nb) 00798 { 00799 // It is the end of move then update file information 00800 fat_get_entry_info(); 00801 return TRUE; // NB FILE FIND 00802 } 00803 u16_nb--; 00804 continue; 00805 } 00806 } 00807 00808 // Here error, check type of error 00809 if(( FS_ERR_ENTRY_EMPTY == fs_g_status ) 00810 || ( FS_ERR_OUT_LIST == fs_g_status ) ) 00811 { 00812 // Here, end of the directory 00813 if( b_find_last_entry ) 00814 { 00815 // Re enable the previous command at the end of directory to find the last directory entry 00816 b_find_last_entry = FALSE; 00817 fs_g_nav.b_mode_nav = FS_DIR; 00818 continue; 00819 } 00820 // Here, a next action is on going 00821 if ( (FS_FILE == fs_g_nav.b_mode_nav) || fs_g_nav.b_mode_nav_single ) 00822 { 00823 // End of next file action then end of next action 00824 fs_g_status = FS_ERR_NO_FIND; // No file found 00825 break; // end of search 00826 }else{ 00827 // End of next dir action then starts the next file action at the beginning of directory 00828 fs_g_nav_fast.u16_entry_pos_sel_file = 0xFFFF; 00829 fs_g_nav.b_mode_nav = FS_FILE; 00830 } 00831 } 00832 } // end of loop while(1) 00833 00834 fs_g_nav.b_mode_nav = b_save_entry_type; 00835 fs_g_nav_fast.u16_entry_pos_sel_file = u16_ptr_save_entry; 00836 fs_g_nav.u16_pos_sel_file = u16_save_pos_sel_file; 00837 return FALSE; 00838 }
Bool nav_filelist_single_disable | ( | void | ) |
To display in File List the directories AND files.
TRUE otherwise
Definition at line 664 of file navigation.c.
References Fs_management::b_mode_nav_single, fs_g_nav, and nav_filelist_reset().
Referenced by nav_filterlist_nb_ex().
00665 { 00666 fs_g_nav.b_mode_nav_single = FALSE; 00667 return nav_filelist_reset(); 00668 }
Bool nav_filelist_single_enable | ( | Bool | b_type | ) |
To display in File List only the files OR directories.
b_type | FS_DIR to display only directories presence FS_FILE to dispaly only files presence |
TRUE otherwise
Definition at line 648 of file navigation.c.
References Fs_management::b_mode_nav, Fs_management::b_mode_nav_single, fs_g_nav, and nav_filelist_reset().
Referenced by nav_filterlist_nb_ex().
00649 { 00650 if ( !nav_filelist_reset()) 00651 return FALSE; 00652 00653 fs_g_nav.b_mode_nav_single = TRUE; 00654 fs_g_nav.b_mode_nav = b_type; 00655 return TRUE; 00656 }
Bool nav_filelist_validpos | ( | void | ) |
This function checks if a file is selected.
FALSE if no file is selected
Definition at line 692 of file navigation.c.
References fat_check_mount_select_noopen().
Referenced by nav_flat_validpos(), navauto_mov_explorer_rec(), navauto_mov_playlist(), navauto_open(), and pl_sel_isvalid().
00693 { 00694 return fat_check_mount_select_noopen(); 00695 }
U8 nav_get | ( | void | ) |
This function returns the navigation identifier used.
Definition at line 260 of file navigation.c.
References fs_g_u8_nav_selected.
Referenced by nav_file_paste_start(), nav_file_paste_state(), pl_add(), pl_main_close(), pl_main_modify(), pl_main_open(), pl_main_save(), pl_nav_readentry(), pl_nav_setpos(), pl_rem_dead(), pl_rem_sel(), and pl_rem_sel_all().
00261 { 00262 #if (FS_NB_NAVIGATOR > 1) 00263 return fs_g_u8_nav_selected; 00264 #else 00265 return 0; 00266 #endif 00267 }
Bool nav_getcwd | ( | FS_STRING | sz_path, | |
U8 | u8_size_path, | |||
Bool | b_view_file_select | |||
) |
This function returns the full path of the selection.
sz_path | string to store the path (ASCII or UNICODE ) | |
u8_size_path | string size (unit ASCII or UNICODE ) | |
b_view_file_select | TRUE, to include in path the selected file name |
TRUE otherwise
Definition at line 1411 of file navigation.c.
References fat_check_mount_noopen(), fat_check_select(), FS_ERR_BUFFER_FULL, FS_ERR_IS_ROOT, fs_g_status, FS_NAME_GET, g_b_string_length, Is_unicode, nav_dir_gotoparent(), nav_drive_getname(), nav_file_name(), nav_getindex(), and nav_gotoindex().
Referenced by pl_add().
01412 { 01413 _MEM_TYPE_SLOW_ Fs_index index; 01414 _MEM_TYPE_SLOW_ U16 u16_lgt=0; // Only used if LENGTH string mode enabled 01415 U8 u8_save_size_path=0, u8_i; 01416 Bool status = FALSE; // Error by default 01417 01418 if ( !fat_check_mount_noopen()) 01419 return FALSE; 01420 01421 index = nav_getindex(); // Save current position 01422 01423 if( g_b_string_length ) 01424 { 01425 u16_lgt = 1; // 1 for NULL terminate 01426 } 01427 else 01428 { 01429 u8_save_size_path = u8_size_path; 01430 // Set NULL terminator at the end of path 01431 u8_size_path--; 01432 if( Is_unicode ) 01433 { 01434 ((FS_STR_UNICODE)sz_path )[u8_size_path] = 0; 01435 }else{ 01436 sz_path [u8_size_path] = 0; 01437 } 01438 } 01439 01440 // For each directory of path 01441 while( 1 ) 01442 { 01443 if( b_view_file_select ) 01444 { 01445 // Write the selected file or directory in path 01446 b_view_file_select = FALSE; 01447 if( !fat_check_select() ) 01448 continue; // No selected file or directory, then restart loop to go at the first directory of path 01449 } 01450 else 01451 { 01452 // Go to parent directory and selects the children directory 01453 if( !nav_dir_gotoparent() ) 01454 break; 01455 } 01456 01457 // Read name of selected file or directory 01458 if( !nav_file_name( sz_path , u8_size_path , FS_NAME_GET, FALSE )) 01459 break; 01460 01461 if( g_b_string_length ) 01462 { 01463 // Update total length 01464 u16_lgt += ((FS_STR_UNICODE)sz_path )[0]; // 0 = -1 to remove NULL terminated and +1 for '\\' 01465 continue; 01466 } 01467 01468 // Compute the size of name 01469 u8_i = 0; 01470 while( 1 ) 01471 { 01472 if( Is_unicode ) 01473 { 01474 if( 0 == ((FS_STR_UNICODE)sz_path )[u8_i]) 01475 break; 01476 }else{ 01477 if( 0 == sz_path [u8_i]) 01478 break; 01479 } 01480 u8_i++; 01481 } 01482 01483 // Check the string size 01484 if( (u8_i+1) == u8_size_path ) 01485 { 01486 fs_g_status = FS_ERR_BUFFER_FULL; // The path string is full 01487 break; 01488 } 01489 01490 // Move the name at the end of path 01491 while( 0 != u8_i ) 01492 { 01493 u8_i--; 01494 u8_size_path--; 01495 if( Is_unicode ) 01496 { 01497 ((FS_STR_UNICODE)sz_path )[u8_size_path] = ((FS_STR_UNICODE)sz_path )[u8_i]; 01498 }else{ 01499 sz_path [u8_size_path] = sz_path [u8_i]; 01500 } 01501 } 01502 // Set '\' char before the name 01503 u8_size_path--; 01504 if( Is_unicode ) 01505 { 01506 ((FS_STR_UNICODE)sz_path )[u8_size_path] = '\\'; 01507 }else{ 01508 sz_path [u8_size_path] = '\\'; 01509 } 01510 } 01511 01512 if ( FS_ERR_IS_ROOT == fs_g_status ) 01513 { 01514 if( g_b_string_length ) 01515 { 01516 // Update and write total length 01517 ((FS_STR_UNICODE)sz_path )[0] = u16_lgt +2 ; //+2 for "x:" 01518 status = TRUE; 01519 } 01520 else 01521 { 01522 // End of path then add device name 01523 if( 2 > u8_size_path ) 01524 { 01525 fs_g_status = FS_ERR_BUFFER_FULL; // The path string is full 01526 } 01527 else 01528 { 01529 // Create a device name 01530 if( Is_unicode ) 01531 { 01532 ((FS_STR_UNICODE)sz_path )[0] = nav_drive_getname(); // Letter 01533 ((FS_STR_UNICODE)sz_path )[1] = ':'; // ":" 01534 }else{ 01535 sz_path [0] = nav_drive_getname(); // Letter 01536 sz_path [1] = ':'; // ":" 01537 } 01538 01539 // The path is stored at the end, then move the path at the beginning 01540 u8_i = 2; 01541 while( u8_save_size_path != u8_size_path ) 01542 { 01543 if( Is_unicode ) 01544 { 01545 ((FS_STR_UNICODE)sz_path )[u8_i] = ((FS_STR_UNICODE)sz_path )[u8_size_path]; 01546 }else{ 01547 sz_path [u8_i] = sz_path [u8_size_path]; 01548 } 01549 u8_i++; 01550 u8_size_path++; 01551 } 01552 status = TRUE; 01553 } 01554 } 01555 } // else Error system 01556 01557 nav_gotoindex( &index ); // Restore the position 01558 return status; 01559 }
Fs_index nav_getindex | ( | void | ) |
This function returns a small index on the selected file.
//! This routine is interresting to save a file position in small variable. //! This pointer allow to reinit a navigator quickly with nav_gotoindex() routine. //!
Definition at line 1093 of file navigation.c.
References fs_g_nav, fs_g_nav_fast, Fs_management_fast::u16_entry_pos_sel_file, Fs_index::u16_entry_pos_sel_file, Fs_management::u32_cluster_sel_dir, Fs_index::u32_cluster_sel_dir, Fs_management::u8_lun, Fs_index::u8_lun, Fs_management::u8_partition, and Fs_index::u8_partition.
Referenced by main(), nav_filterflat_gotoparent(), nav_flat_gotoparent(), nav_getcwd(), nav_partition_label(), nav_setcwd(), navauto_open(), pl_main_close(), pl_main_modify(), and pl_main_save().
01094 { 01095 Fs_index index; 01096 01097 // Fill index structure 01098 index.u8_lun = fs_g_nav.u8_lun; 01099 #if (FS_MULTI_PARTITION == ENABLED) 01100 index.u8_partition = fs_g_nav.u8_partition; 01101 #endif 01102 index.u32_cluster_sel_dir = fs_g_nav.u32_cluster_sel_dir; 01103 index.u16_entry_pos_sel_file = fs_g_nav_fast.u16_entry_pos_sel_file; 01104 return index; 01105 }
Bool nav_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 1120 of file navigation.c.
References FS_FIND_NEXT, fs_g_nav, fs_g_nav_fast, nav_drive_set(), nav_filelist_reset(), nav_filelist_set(), nav_partition_mount(), nav_partition_set(), Fs_management_fast::u16_entry_pos_sel_file, and Fs_management::u32_cluster_sel_dir.
Referenced by main(), nav_filterflat_gotoparent(), nav_flat_gotoparent(), nav_getcwd(), nav_partition_label(), nav_setcwd(), navauto_open(), pl_main_close(), pl_main_modify(), pl_main_save(), and pl_rem_dead().
01121 { 01122 // Select the drive and partition corresponding at file index 01123 if( !nav_drive_set( index->u8_lun )) 01124 return FALSE; 01125 #if (FS_MULTI_PARTITION == ENABLED) 01126 if( !nav_partition_set(index->u8_partition)) 01127 return FALSE; 01128 #endif 01129 if( !nav_partition_mount()) 01130 return FALSE; 01131 01132 // Select the directory corresponding at file index 01133 fs_g_nav.u32_cluster_sel_dir = index->u32_cluster_sel_dir; 01134 01135 // Search the file position corresponding at file index 01136 if ( !nav_filelist_reset()) 01137 return FALSE; 01138 while( fs_g_nav_fast.u16_entry_pos_sel_file != index->u16_entry_pos_sel_file ) 01139 { 01140 if( !nav_filelist_set( 0 , FS_FIND_NEXT ) ) 01141 { 01142 nav_filelist_reset(); 01143 return FALSE; 01144 } 01145 } 01146 return TRUE; 01147 }
U8 nav_partition_cluster_size | ( | void | ) |
This function returns the partition cluster size.
Definition at line 595 of file navigation.c.
References fs_g_nav, and Fs_management::u8_BPB_SecPerClus.
00596 { 00597 return fs_g_nav.u8_BPB_SecPerClus; 00598 }
U32 nav_partition_freespace | ( | void | ) |
This function returns the partition free space.
0 in case of error or full partition
//! You shall mounted the partition before call this routine //!
Definition at line 609 of file navigation.c.
References fat_check_device(), fat_getfreespace(), fs_g_nav_fast, FS_TYPE_FAT_UNM, and Fs_management_fast::u8_type_fat.
Referenced by main().
00610 { 00611 fat_check_device(); 00612 if (FS_TYPE_FAT_UNM == fs_g_nav_fast.u8_type_fat) 00613 return 0; 00614 return fat_getfreespace(); 00615 }
U8 nav_partition_freespace_percent | ( | void | ) |
This function returns the partition space free in percent.
0% in case of error or full partition
//! To speed up the compute, the resultat have an error delta of 1% //!
Definition at line 627 of file navigation.c.
References fat_check_device(), fat_getfreespace_percent(), fs_g_nav_fast, FS_TYPE_FAT_UNM, and Fs_management_fast::u8_type_fat.
00628 { 00629 fat_check_device(); 00630 if (FS_TYPE_FAT_UNM == fs_g_nav_fast.u8_type_fat) 00631 return 0; 00632 return fat_getfreespace_percent(); 00633 }
Bool nav_partition_label | ( | Bool | b_action, | |
FS_STRING | sz_label | |||
) |
This function reads or writes the label of selected partition.
b_action | to select the action FS_LABEL_READ to read label FS_LABEL_WRITE to write label | |
sz_label | pointer on a ASCII string (11 chars + NULL terminator =12 bytes) if FS_LABEL_READ, then the string is used to store label if FS_LABEL_WRITE, then the string is used to give the new label |
TRUE otherwise
Definition at line 529 of file navigation.c.
References fat_entry_label(), fat_read_dir(), FS_ERR_ENTRY_EMPTY, fs_g_nav_fast, fs_g_status, FS_LABEL_READ, FS_LABEL_WRITE, nav_dir_root(), nav_getindex(), nav_gotoindex(), and Fs_management_fast::u16_entry_pos_sel_file.
00530 { 00531 _MEM_TYPE_SLOW_ Fs_index index; 00532 Bool status = TRUE; 00533 00534 index = nav_getindex(); // Save current position 00535 00536 // Go to root dir 00537 if( nav_dir_root()) 00538 { 00539 // Find field label 00540 fs_g_nav_fast.u16_entry_pos_sel_file = 0; // Go to first entry 00541 while( 1 ) 00542 { 00543 if ( !fat_read_dir()) 00544 { 00545 status = FALSE; 00546 break; // error 00547 } 00548 if( fat_entry_label( FS_LABEL_READ , NULL ) ) 00549 break; 00550 if( FS_ERR_ENTRY_EMPTY == fs_g_status ) 00551 break; 00552 fs_g_nav_fast.u16_entry_pos_sel_file++; 00553 } 00554 if( TRUE == status ) 00555 { 00556 // Find OK 00557 if( FS_LABEL_READ == b_action ) 00558 { 00559 // Read field label 00560 if( !fat_entry_label( FS_LABEL_READ , sz_label ) ) 00561 sz_label[0]=0; // empty name 00562 }else{ 00563 // Change field label 00564 status = fat_entry_label( FS_LABEL_WRITE , sz_label ); 00565 } 00566 } 00567 } 00568 nav_gotoindex( &index ); // Restore the position 00569 return status; 00570 }
Bool nav_partition_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 //!
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 461 of file navigation.c.
References fat_check_noopen(), fat_clear_entry_info_and_ptr(), fat_mount(), fs_g_nav, fs_g_nav_fast, FS_TYPE_FAT_UNM, Fs_management::u32_cluster_sel_dir, and Fs_management_fast::u8_type_fat.
Referenced by main(), nav_dir_root(), nav_filterlist_gotoindex(), nav_filterlist_mount(), nav_flat_mount(), nav_gotoindex(), nav_partition_type(), nav_setcwd(), and navauto_mov_ok_loop().
00462 { 00463 if ( !fat_check_noopen() ) 00464 return FALSE; 00465 00466 if( FS_TYPE_FAT_UNM != fs_g_nav_fast.u8_type_fat) 00467 { 00468 // Already mounted 00469 // Go to root directory 00470 fs_g_nav.u32_cluster_sel_dir = 0; 00471 // No file is selected by default 00472 fat_clear_entry_info_and_ptr(); 00473 return TRUE; 00474 } 00475 00476 return fat_mount(); 00477 }
U8 nav_partition_nb | ( | void | ) |
This function returns the number of partitions present on drive.
Definition at line 421 of file navigation.c.
References fat_get_nbpartition().
00422 { 00423 return fat_get_nbpartition(); 00424 }
Bool nav_partition_serialnumber | ( | Bool | b_action, | |
U8 _MEM_TYPE_SLOW_ * | a_u8_sn | |||
) |
This function reads or writes the serial number on the selected partition.
b_action | to select the action FS_SN_READ to read serial number FS_SN_WRITE to write serial number | |
a_u8_sn | pointer on an array (4 bytes) if FS_SN_READ, then the array is used to store the serial number if FS_SN_WRITE, then the array is used to give the new serial number |
TRUE otherwise
Definition at line 508 of file navigation.c.
References fat_check_mount(), and fat_serialnumber().
00509 { 00510 if( !fat_check_mount()) 00511 return FALSE; 00512 00513 return fat_serialnumber( b_action , a_u8_sn ); 00514 }
Bool nav_partition_set | ( | U8 | partition_number | ) |
This function selects a partition on drive.
partition_number | partition number (0 to 3) |
TRUE otherwise
Definition at line 434 of file navigation.c.
References fat_check_noopen(), fs_g_nav, fs_g_nav_fast, FS_TYPE_FAT_UNM, Fs_management::u8_partition, and Fs_management_fast::u8_type_fat.
Referenced by nav_filterlist_gotoindex(), and nav_gotoindex().
00435 { 00436 if ( fs_g_nav.u8_partition == partition_number) 00437 return TRUE; // It is the same 00438 00439 if ( !fat_check_noopen() ) 00440 return FALSE; 00441 00442 // Go to partition 00443 fs_g_nav.u8_partition = partition_number; 00444 fs_g_nav_fast.u8_type_fat = FS_TYPE_FAT_UNM; 00445 return TRUE; 00446 }
U32 nav_partition_space | ( | void | ) |
This function returns partition total space.
0, in case of error
//! You shall mounted the partition before call this routine //!
Definition at line 582 of file navigation.c.
References fat_check_device(), fs_g_nav, fs_g_nav_fast, FS_TYPE_FAT_UNM, Fs_management::u32_CountofCluster, Fs_management::u8_BPB_SecPerClus, and Fs_management_fast::u8_type_fat.
Referenced by main().
00583 { 00584 fat_check_device(); 00585 if (FS_TYPE_FAT_UNM == fs_g_nav_fast.u8_type_fat) 00586 return 0; 00587 return (fs_g_nav.u32_CountofCluster * fs_g_nav.u8_BPB_SecPerClus); 00588 }
U8 nav_partition_type | ( | void | ) |
This function gives the partition type.
FS_TYPE_FAT_UNM, in case of error or unknow format
Definition at line 485 of file navigation.c.
References fat_check_device(), fs_g_nav_fast, FS_TYPE_FAT_UNM, nav_partition_mount(), and Fs_management_fast::u8_type_fat.
Referenced by main().
00486 { 00487 fat_check_device(); 00488 if( FS_TYPE_FAT_UNM == fs_g_nav_fast.u8_type_fat) 00489 { 00490 nav_partition_mount(); 00491 } 00492 return fs_g_nav_fast.u8_type_fat; 00493 }
void nav_reset | ( | void | ) |
This function resets ALL navigations to init file system core.
//! Call this at the program startup or before a new session (e.g. USB Device exit) //!
Definition at line 165 of file navigation.c.
References Fs_management::b_mode_nav_single, fat_cache_clusterlist_reset(), fat_cache_reset(), Fat_file_close, fs_g_nav, fs_g_nav_fast, fs_g_u8_nav_selected, FS_NB_NAVIGATOR, FS_TYPE_FAT_UNM, g_b_no_check_disk, g_b_string_length, g_b_unicode, nav_select(), Fs_management::u8_lun, Fs_management::u8_partition, and Fs_management_fast::u8_type_fat.
Referenced by b_fsaccess_init(), and main().
00166 { 00167 #if ( (FS_ASCII == ENABLED) && (FS_UNICODE == ENABLED)) 00168 g_b_unicode = TRUE; 00169 #endif 00170 g_b_string_length = FALSE; 00171 g_b_no_check_disk = FALSE; 00172 00173 fat_cache_reset(); 00174 fat_cache_clusterlist_reset(); 00175 00176 #if (FS_NB_NAVIGATOR > 1) 00177 { 00178 U8 i; 00179 // Reset variables of each navigators 00180 for( i=0 ; i!=FS_NB_NAVIGATOR ; i++ ) 00181 { 00182 nav_select(i); 00183 fs_g_nav_fast.u8_type_fat = FS_TYPE_FAT_UNM; // By default the fat isn't mounted 00184 fs_g_nav.u8_lun = 0xFF; // By default don't select a drive 00185 #if (FS_MULTI_PARTITION == ENABLED) 00186 fs_g_nav.u8_partition=0; // By default select the first partition 00187 #endif 00188 Fat_file_close(); // By default no file is opened 00189 fs_g_nav.b_mode_nav_single = FALSE; // By default display files and directories 00190 } 00191 // By default select the navigator 0 00192 fs_g_u8_nav_selected = 0; 00193 } 00194 #else 00195 fs_g_nav_fast.u8_type_fat = FS_TYPE_FAT_UNM; // By default the fat isn't mounted 00196 fs_g_nav.u8_lun = 0xFF; // By default don't select a drive 00197 # if (FS_MULTI_PARTITION == ENABLED) 00198 fs_g_nav.u8_partition=0; // By default select the first partition 00199 # endif 00200 Fat_file_close(); // By default no file is opened 00201 #endif // (FS_NB_NAVIGATOR > 1) 00202 }
Bool nav_select | ( | U8 | u8_idnav | ) |
This function selects the navigation to use.
u8_idnav | navigator identifier to select (0 to FS_NB_NAVIGATOR-1) |
TRUE otherwise
Definition at line 237 of file navigation.c.
References fat_invert_nav(), FS_ERR_BAD_NAV, fs_g_status, fs_g_u8_nav_selected, and FS_NB_NAVIGATOR.
Referenced by close(), fsaccess_file_get_size(), fsaccess_IsDirPresent(), nav_exit(), nav_file_paste_start(), nav_file_paste_state(), nav_reset(), open(), pl_add(), pl_main_close(), pl_main_modify(), pl_main_open(), pl_main_readline(), pl_main_save(), pl_nav_readentry(), pl_nav_setpos(), pl_rem_dead(), pl_rem_sel(), pl_rem_sel_all(), read(), and write().
00238 { 00239 if( FS_NB_NAVIGATOR <= u8_idnav ) 00240 { 00241 fs_g_status = FS_ERR_BAD_NAV; // The navigator doesn't exist 00242 return FALSE; 00243 } 00244 #if (FS_NB_NAVIGATOR > 1) 00245 if( fs_g_u8_nav_selected != u8_idnav ) 00246 { 00247 fat_invert_nav( fs_g_u8_nav_selected ); // Deselect previous navigator = Select default navigator 00248 fat_invert_nav( u8_idnav ); // Select new navigator 00249 fs_g_u8_nav_selected = u8_idnav; 00250 } 00251 #endif 00252 return TRUE; 00253 }
Bool nav_setcwd | ( | FS_STRING | sz_path, | |
Bool | b_match_case, | |||
Bool | b_create | |||
) |
This function selects a disk position via a path.
sz_path | path string (ASCII or UNICODE ) | |
b_match_case | FALSE to ignore the case | |
b_create | TRUE, if path no exists then create it FALSE, no create path |
TRUE otherwise
//! The syntact "./../../file_name" is supported. //! With syntact "./dir_parent/directory_name" the file list corresponding at "dir_parent" and "directory_name" is selected. //! With syntact "./dir_parent/directory_name/" the file list corresponding at "directory_name" and no file is selected. //!
Definition at line 1578 of file navigation.c.
References fat_check_noopen(), fat_entry_is_dir(), Is_unicode, nav_dir_cd(), nav_dir_gotoparent(), nav_dir_make(), nav_dir_root(), nav_drive_set(), nav_file_create(), nav_filelist_findname(), nav_filelist_reset(), nav_getindex(), nav_gotoindex(), and nav_partition_mount().
Referenced by fsaccess_IsDirPresent(), main(), open(), and pl_main_readline().
01579 { 01580 _MEM_TYPE_SLOW_ Fs_index index; 01581 #if (FSFEATURE_WRITE == (FS_LEVEL_FEATURES & FSFEATURE_WRITE)) || \ 01582 (FSFEATURE_WRITE_COMPLET == (FS_LEVEL_FEATURES & FSFEATURE_WRITE_COMPLET)) 01583 FS_STRING sz_save_path = 0; 01584 #endif 01585 Bool b_create_name = FALSE; 01586 01587 if ( !fat_check_noopen()) 01588 return FALSE; 01589 01590 index = nav_getindex(); // Save current position 01591 01592 // Check syntact "\path..." 01593 if( (( Is_unicode) && (('\\' == ((FS_STR_UNICODE)sz_path )[0]) || ('/' == ((FS_STR_UNICODE)sz_path )[0])) ) 01594 || ((!Is_unicode) && (('\\' == sz_path [0]) || ('/' == sz_path [0])) ) ) 01595 { 01596 // Go to the root of current drive 01597 if( !nav_dir_root()) 01598 goto nav_setcwd_fail; 01599 sz_path += (Is_unicode? 2 : 1 ); 01600 }else 01601 01602 // Check syntact "x:\path..." 01603 if( (( Is_unicode) && (( ':' == ((FS_STR_UNICODE)sz_path )[1] ) && (('\\' == ((FS_STR_UNICODE)sz_path )[2] ) || ('/' == ((FS_STR_UNICODE)sz_path )[2]))) ) 01604 || ((!Is_unicode) && (( ':' == sz_path [1] ) && (('\\' == sz_path [2] ) || ('/' == sz_path [2]))) ) ) 01605 { 01606 // Go to the drive 01607 if( Is_unicode ) 01608 { 01609 if( !nav_drive_set( toupper(((FS_STR_UNICODE)sz_path )[0])-'A' ) ) 01610 goto nav_setcwd_fail; 01611 }else{ 01612 if( !nav_drive_set( toupper(sz_path [0])-'A' ) ) 01613 goto nav_setcwd_fail; 01614 } 01615 if( !nav_partition_mount()) 01616 goto nav_setcwd_fail; 01617 sz_path += 3*(Is_unicode? 2 : 1 ); 01618 }else 01619 01620 // Check syntact ".\path..." 01621 if( (( Is_unicode) && (( '.' == ((FS_STR_UNICODE)sz_path )[0] ) && (('\\' == ((FS_STR_UNICODE)sz_path )[1] ) || ('/' == ((FS_STR_UNICODE)sz_path )[1] ))) ) 01622 || ((!Is_unicode) && (( '.' == sz_path [0] ) && (('\\' == sz_path [1] ) || ('/' == sz_path [1] ))) ) ) 01623 { 01624 // Search in current directory 01625 sz_path += 2*(Is_unicode? 2 : 1 ); 01626 }else 01627 01628 { 01629 // Check syntact "..\..\path..." 01630 if( Is_unicode ) 01631 { 01632 while(( '.' == ((FS_STR_UNICODE)sz_path )[0] ) 01633 && ( '.' == ((FS_STR_UNICODE)sz_path )[1] ) 01634 && (('\\' == ((FS_STR_UNICODE)sz_path )[2]) || ('/' == ((FS_STR_UNICODE)sz_path )[2]) || (0 == ((FS_STR_UNICODE)sz_path )[2])) ) 01635 { 01636 // Go to parent directory 01637 if( !nav_dir_gotoparent() ) 01638 goto nav_setcwd_fail; 01639 sz_path += (2*2); // jump ".." 01640 if( 0 != ((FS_STR_UNICODE)sz_path )[0]) 01641 sz_path += (2*1); // jump "/" 01642 } 01643 }else{ 01644 while(( '.' == sz_path [0] ) 01645 && ( '.' == sz_path [1] ) 01646 && (('\\' == sz_path [2]) || ('/' == sz_path [2]) || (0 == sz_path [2])) ) 01647 { 01648 // Go to parent directory 01649 if( !nav_dir_gotoparent() ) 01650 goto nav_setcwd_fail; 01651 sz_path += 2; // jump ".." 01652 if( 0 != sz_path [0]) 01653 sz_path +=1; // jump "/" 01654 } 01655 } 01656 } 01657 01658 // Reset list to start the search at the beginning 01659 if( !nav_filelist_reset()) 01660 goto nav_setcwd_fail; 01661 01662 while( 1 ) 01663 { 01664 if( (( Is_unicode) && ( 0 == ((FS_STR_UNICODE)sz_path )[0] ) ) 01665 || ((!Is_unicode) && ( 0 == sz_path [0] ) ) ) 01666 { 01667 return TRUE; // path (without file) is found or create 01668 } 01669 if( !nav_filelist_findname( sz_path , b_match_case )) 01670 { 01671 // The file or directory is not found 01672 if( !b_create ) 01673 goto nav_setcwd_fail; // don't creat the directory then exit 01674 // Set flag to create the directory 01675 b_create_name = TRUE; 01676 #if (FSFEATURE_WRITE == (FS_LEVEL_FEATURES & FSFEATURE_WRITE)) || \ 01677 (FSFEATURE_WRITE_COMPLET == (FS_LEVEL_FEATURES & FSFEATURE_WRITE_COMPLET)) 01678 sz_save_path = sz_path; 01679 #endif 01680 } 01681 01682 while( 1 ) 01683 { 01684 sz_path += (Is_unicode? 2 : 1 ); 01685 if( (( Is_unicode) && ( 0 == ((FS_STR_UNICODE)sz_path )[0] ) ) 01686 || ((!Is_unicode) && ( 0 == sz_path [0] ) ) ) 01687 { 01688 // Is it the last name of path and it is a file 01689 if( b_create_name ) 01690 { 01691 #if (FSFEATURE_WRITE == (FS_LEVEL_FEATURES & FSFEATURE_WRITE)) 01692 // The file must be created 01693 if( !nav_file_create( sz_save_path ) ) 01694 goto nav_setcwd_fail; 01695 #else 01696 goto nav_setcwd_fail; 01697 #endif 01698 } 01699 break; // The file include in path is found or created, then end of set_cwd 01700 } 01701 01702 if( (( Is_unicode) && (('\\' == ((FS_STR_UNICODE)sz_path )[0] ) || ('/' == ((FS_STR_UNICODE)sz_path )[0] )) ) 01703 || ((!Is_unicode) && (('\\' == sz_path [0] ) || ('/' == sz_path [0] )) ) ) 01704 { 01705 // Is it a folder name 01706 if( b_create_name ) 01707 { 01708 #if (FSFEATURE_WRITE_COMPLET == (FS_LEVEL_FEATURES & FSFEATURE_WRITE_COMPLET)) 01709 // The folder doesn't exist and it must be created 01710 if( !nav_dir_make( sz_save_path )) 01711 goto nav_setcwd_fail; 01712 #else 01713 goto nav_setcwd_fail; 01714 #endif 01715 } 01716 if( !fat_entry_is_dir() ) 01717 goto nav_setcwd_fail; 01718 // jump '\' 01719 sz_path += (Is_unicode? 2 : 1 ); 01720 if( !nav_dir_cd()) 01721 goto nav_setcwd_fail; 01722 break; 01723 } 01724 } 01725 01726 } 01727 01728 nav_setcwd_fail: 01729 nav_gotoindex( &index ); // Restore the position 01730 return FALSE; 01731 }
void nav_string_ascii | ( | void | ) |
This function selects the ASCII mode for all routines with FS_STRING parameter.
//! If you have enabled the FS_ASCII AND FS_UNICODE define //! then FS_STRING parameter can be a ASCII or UNICODE string. //!
Definition at line 98 of file navigation.c.
References g_b_unicode.
Referenced by pl_add(), and pl_main_modify().
00099 { 00100 g_b_unicode = FALSE; 00101 }
void nav_string_length_disable | ( | void | ) |
This function deselects the LENGTH string mode for all routines with FS_STRING parameter.
//! In LENGTH string mode when you call a routine with FS_STRING parameter //! only the size (16bits, unit ASCII or UNICODE) is returned in the first 16bits of string array. //!
Definition at line 122 of file navigation.c.
References g_b_string_length.
Referenced by pl_main_close().
00123 { 00124 g_b_string_length = FALSE; 00125 }
void nav_string_length_enable | ( | void | ) |
This function selects the LENGTH string mode for all routines with FS_STRING parameter.
//! In LENGTH string mode when you call a routine with FS_STRING parameter //! only the size (16bits, unit ASCII or UNICODE) is returned in the first 16bits of string array. //!
Definition at line 111 of file navigation.c.
References g_b_string_length.
Referenced by pl_main_close().
00112 { 00113 g_b_string_length = TRUE; 00114 }
void nav_string_unicode | ( | void | ) |
This function selects the UNICODE mode for all routines with FS_STRING parameter.
//! If you have enabled the FS_ASCII AND FS_UNICODE define //! then FS_STRING parameter can be a ASCII or UNICODE string. //!
Definition at line 87 of file navigation.c.
References g_b_unicode.
Referenced by pl_add(), and pl_main_modify().
00088 { 00089 g_b_unicode = TRUE; 00090 }