Microchip® Advanced Software Framework

navigation.c File Reference
#include <ctype.h>
#include "conf_explorer.h"
#include "navigation.h"
#include "file.h"
#include "ctrl_access.h"

Macros

#define SIZE_OF_SPLIT_COPY   ((1*1024*1024L)/512L)
 

Functions

void nav_checkdisk_disable (void)
 This function disables the disk check before each actions on disk. More...
 
void nav_checkdisk_enable (void)
 This function enables the disk check before each actions on disk. More...
 
bool nav_copy (uint8_t u8_idnav)
 This function copies the navigator information to another navigator. More...
 
bool nav_dir_cd (void)
 This function enters in the selected directory in file list. More...
 
bool nav_dir_gotoparent (void)
 This function goes to the parent directory. More...
 
bool nav_dir_is_root (void)
 This function check the current directory. More...
 
bool nav_dir_make (const FS_STRING sz_name)
 This function creates a directory in the directory corresponding at file list. More...
 
bool nav_dir_name (FS_STRING sz_path, uint8_t u8_size_max)
 This function returns the directory name corresponding at the file list. More...
 
bool nav_dir_root (void)
 This function initializes the file list on the root directory. More...
 
bool nav_drive_format (uint8_t u8_fat_type)
 This function formats the current drive (=disk) More...
 
uint8_t nav_drive_get (void)
 This function returns the selected drive number. More...
 
uint8_t nav_drive_getname (void)
 This function returns the selected drive letter. More...
 
uint8_t nav_drive_nb (void)
 This function returns the number of devices available. More...
 
bool nav_drive_set (uint8_t u8_number)
 This function selects a drive in navigator but don't mount the disk partition. More...
 
void nav_exit (void)
 This function flush ALL navigations before exit of file system core. More...
 
uint8_t nav_file_attributget (void)
 This function returns the Attribute of selected file. More...
 
bool nav_file_attributset (uint8_t u8_attribut)
 This function changes the Attribute of selected file. More...
 
bool nav_file_checkext (const FS_STRING sz_filterext)
 This function checks the extension of selected file. More...
 
bool nav_file_copy (void)
 This function updates the COPY navigator with the selected file. More...
 
bool nav_file_create (const FS_STRING sz_name)
 This function creates a file with NULL size and NULL Attribute. More...
 
bool nav_file_dateget (FS_STRING sz_date, bool type_date)
 This function returns the date of selected file. More...
 
bool nav_file_dateset (const FS_STRING sz_date, bool type_date)
 This function changes the date of selected file. More...
 
bool nav_file_del (bool b_only_empty)
 This function deletes the selected file or directory. More...
 
bool nav_file_getname (FS_STRING sz_name, uint8_t u8_size_max)
 This function returns the name of selected file. More...
 
bool nav_file_isdir (void)
 This function returns the type of selected file. More...
 
bool nav_file_isreadonly (void)
 This function checks the write protection of disk and the Attribute "read only" of selected file. More...
 
uint32_t nav_file_lgt (void)
 This function returns the size of selected file (unit byte) More...
 
uint16_t nav_file_lgtsector (void)
 This function returns the size of selected file (unit sector) More...
 
bool nav_file_name (FS_STRING sz_name, uint8_t 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. More...
 
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. More...
 
uint8_t nav_file_paste_state (bool b_stop)
 This function executes the copy file. More...
 
bool nav_file_rename (const FS_STRING sz_name)
 This function renames the selected directory or file. More...
 
bool nav_filelist_bol (void)
 This function checks the beginning of file list. More...
 
bool nav_filelist_eol (void)
 This function checks the end of file list. More...
 
bool nav_filelist_exist (bool b_type)
 This function checks the presence of files or directories in file list. More...
 
bool nav_filelist_fileisnotopen (void)
 This function checks if no file is open. More...
 
bool nav_filelist_findname (const FS_STRING sz_name, bool b_match_case)
 This function searches a file name in file list. More...
 
bool nav_filelist_first (bool b_type)
 This function goes to at the first file or directory in file list. More...
 
uint16_t nav_filelist_get (void)
 This function returns the position of selected file in file list. More...
 
bool nav_filelist_goto (uint16_t u16_newpos)
 This function goes at a position in file list. More...
 
bool nav_filelist_last (bool b_type)
 This function goes to at the last file or directory in file list. More...
 
uint16_t nav_filelist_nb (bool b_type)
 This function computes the number of files or directories in file list. More...
 
bool nav_filelist_reset (void)
 This function resets the selection pointer, so "no file selected" in file list. More...
 
bool nav_filelist_set (uint16_t u16_nb, bool b_direction)
 This function moves the selection pointer in file list. More...
 
bool nav_filelist_single_disable (void)
 To display in File List the directories AND files. More...
 
bool nav_filelist_single_enable (bool b_type)
 To display in File List only the files OR directories. More...
 
bool nav_filelist_validpos (void)
 This function checks if a file is selected. More...
 
uint8_t nav_get (void)
 This function returns the navigation identifier used. More...
 
bool nav_getcwd (FS_STRING sz_path, uint8_t u8_size_path, bool b_view_file_select)
 This function returns the full path of the selection. More...
 
Fs_index nav_getindex (void)
 This function returns a small index on the selected file. More...
 
bool nav_gotoindex (const Fs_index _MEM_TYPE_SLOW_ *index)
 This function selects a file in the navigator via a file index. More...
 
uint8_t nav_partition_cluster_size (void)
 This function returns the partition cluster size. More...
 
uint32_t nav_partition_freespace (void)
 This function returns the partition free space. More...
 
uint8_t nav_partition_freespace_percent (void)
 This function returns the partition space free in percent. More...
 
bool nav_partition_label (bool b_action, FS_STRING sz_label)
 This function reads or writes the label of selected partition. More...
 
bool nav_partition_mount (void)
 This function mounts the selected partition. More...
 
bool nav_partition_serialnumber (bool b_action, uint8_t _MEM_TYPE_SLOW_ *a_u8_sn)
 This function reads or writes the serial number on the selected partition. More...
 
uint32_t nav_partition_space (void)
 This function returns partition total space. More...
 
uint8_t nav_partition_type (void)
 This function gives the partition type. More...
 
void nav_reset (void)
 This function resets ALL navigations to init file system core. More...
 
bool nav_select (uint8_t u8_idnav)
 This function selects the navigation to use. More...
 
bool nav_setcwd (FS_STRING sz_path, bool b_match_case, bool b_create)
 This function selects a disk position via a path. More...
 
void nav_string_length_disable (void)
 This function deselects the LENGTH string mode for all routines with FS_STRING parameter. More...
 
void nav_string_length_enable (void)
 This function selects the LENGTH string mode for all routines with FS_STRING parameter. More...
 

Variables

_MEM_TYPE_SLOW_ uint8_t fs_g_u8_nav_selected
 Holds the current navigator selected. More...
 
_MEM_TYPE_SLOW_ uint8_t g_id_trans_memtomem = ID_STREAM_ERR
 Holds the current ID transfer used by the internal copy-paste routines. More...
 
_MEM_TYPE_SLOW_ Fs_file_segment g_segment_dest
 
_MEM_TYPE_SLOW_ Fs_file_segment g_segment_src
 

#define SIZE_OF_SPLIT_COPY   ((1*1024*1024L)/512L)

Referenced by nav_file_paste_state().

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 sent at device.
//! This check can reduce the speed access on specific disk.
//! 

References g_b_no_check_disk.

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 sent at device.
//! This check can reduce the speed access on specific disk.
//! 

References g_b_no_check_disk.

bool nav_copy ( uint8_t  u8_idnav)

This function copies the navigator information to another navigator.

@param     u8_idnav       navigator identifier where the main navigator will be copied

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Use this routine to select quickly the same file in another navigator
//! 

References fat_copy_nav(), and fs_g_u8_nav_selected.

Referenced by nav_file_copy().

bool nav_dir_cd ( void  )

This function enters in the selected directory in file list.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  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.
//! 

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_setcwd(), and ushell_cmd_sync().

bool nav_dir_gotoparent ( void  )

This function goes to the parent directory.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  true otherwise
//! 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.
//! 

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_getcwd(), nav_setcwd(), ushell_cmd_gotoparent(), and ushell_cmd_sync().

bool nav_dir_is_root ( void  )

This function check the current directory.

Returns
false the current directory selected is not the root directory
true the current directory selected is the root directory

References fat_check_mount_noopen(), fs_g_nav, and Fs_management::u32_cluster_sel_dir.

bool nav_dir_make ( const FS_STRING  sz_name)

This function creates a directory in the directory corresponding at file list.

Parameters
sz_namedirectory name (ASCII or UNICODE )
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Referenced by nav_setcwd(), ushell_cmd_mkdir(), and ushell_cmd_sync().

bool nav_dir_name ( FS_STRING  sz_path,
uint8_t  u8_size_max 
)

This function returns the directory name corresponding at the file list.

Parameters
sz_pathstring to store the name (ASCII or UNICODE )
u8_size_maxstring size (unit ASCII or UNICODE )
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

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 ushell_cmd_ls().

bool nav_dir_root ( void  )

This function initializes the file list on the root directory.

Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References nav_partition_mount().

Referenced by nav_partition_label(), and nav_setcwd().

bool nav_drive_format ( uint8_t  u8_fat_type)

This function formats the current drive (=disk)

@param     u8_fat_type    Select the format type<br>
           FS_FORMAT_DEFAULT, The system chooses the better FAT format <br>
           FS_FORMAT_FAT, The FAT12 or FAT16 is used to format the drive, if possible (disk space <2GB) <br>
           FS_FORMAT_FAT32, The FAT32 is used to format the drive, if possible (disk space >32MB) <br>
           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)

@return    false in case of error, see global value "fs_g_status" for more detail
@return    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.
//! 

Referenced by ushell_cmd_format().

uint8_t nav_drive_get ( void  )

This function returns the selected drive number.

Returns
0 to nav_drive_nb()-1
0xFF in case of no drive selected

References fs_g_nav, and Fs_management::u8_lun.

Referenced by ushell_cmd_ls(), ushell_cmd_perform(), and ushell_cmd_space().

uint8_t nav_drive_getname ( void  )

This function returns the selected drive letter.

Returns
'A','B',...
'X', in case of no drive selected

References fs_g_nav, and Fs_management::u8_lun.

Referenced by nav_dir_name(), and nav_getcwd().

uint8_t nav_drive_nb ( void  )

This function returns the number of devices available.

@return    number of devices, 0 = NO DEVICE AVAILABLED
//! This value may be dynamic because it depends of memory drivers (e.g. Mass Storage disk on USB host mode)
//! 

References get_nb_lun().

Referenced by ushell_cmd_free_space(), ushell_cmd_mount(), and ushell_cmd_nb_drive().

bool nav_drive_set ( uint8_t  u8_number)

This function selects a drive in navigator but don't mount the disk partition.

Parameters
u8_numberdevice number (0 to nav_drive_nb()-1 )
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

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, and Fs_management_fast::u8_type_fat.

Referenced by nav_gotoindex(), nav_setcwd(), ushell_cmd_format(), ushell_cmd_free_space(), ushell_cmd_mount(), ushell_cmd_perform_alloc(), and ushell_task().

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
//! 

References fat_cache_flush(), file_close(), FS_NB_NAVIGATOR, and nav_select().

Referenced by ushell_task().

uint8_t nav_file_attributget ( void  )

This function returns the Attribute of selected file.

Returns
Attribute of selected file, see masks "FS_ATTR_" in fs_com.h file.

References fs_g_nav_entry, and Fs_management_entry::u8_attr.

bool nav_file_attributset ( uint8_t  u8_attribut)

This function changes the Attribute of selected file.

Parameters
u8_attributvalue to write on selected file, see masks "FS_ATTR_" in fs_com.h file.
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise
bool nav_file_checkext ( const FS_STRING  sz_filterext)

This function checks the extension of selected file.

Parameters
sz_filterextextension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" )
Returns
true, the file extension match with extension filter
false, in other case

References fat_check_mount_select(), fat_entry_checkext(), and fat_read_dir().

Referenced by ushell_cmd_ls().

bool nav_file_copy ( void  )

This function updates the COPY navigator with the selected file.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  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).
//! 

References FS_ERR_COPY_DIR, fs_g_status, FS_NAV_ID_COPYFILE, nav_copy(), and nav_file_isdir().

Referenced by ushell_cmd_copy(), and ushell_cmd_sync().

bool nav_file_create ( const FS_STRING  sz_name)

This function creates a file with NULL size and NULL Attribute.

@param     sz_name     file name to create (ASCII or UNICODE )

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! If you use this routine to create a file, then you must called file_open() to open this new file
//! 

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 nav_file_paste_start(), nav_setcwd(), ushell_cmd_perform_alloc(), and ushell_cmd_touch().

bool nav_file_dateget ( FS_STRING  sz_date,
bool  type_date 
)

This function returns the date of selected file.

Parameters
type_dateFS_DATE_LAST_WRITE, to get the date of last write access
FS_DATE_CREATION, to get the date of file creation
sz_dateASCCI string (>17B) to store the information about date
"YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References fat_check_mount_select(), fat_get_date(), and fat_read_dir().

bool nav_file_dateset ( const FS_STRING  sz_date,
bool  type_date 
)

This function changes the date of selected file.

Parameters
type_dateFS_DATE_LAST_WRITE, to get the date of last write access
FS_DATE_CREATION, to get the date of file creation
sz_dateASCCI string contains the date to write
"YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise
bool nav_file_del ( bool  b_only_empty)

This function deletes the selected file or directory.

Parameters
b_only_emptytrue, 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.
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Referenced by nav_file_paste_state(), ushell_cmd_perform(), ushell_cmd_perform_alloc(), ushell_cmd_rm(), and ushell_cmd_sync().

bool nav_file_getname ( FS_STRING  sz_name,
uint8_t  u8_size_max 
)

This function returns the name of selected file.

Parameters
sz_namestring to store the name file (ASCII or UNICODE )
u8_size_maxstring size (unit ASCII or UNICODE )
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References FS_NAME_GET, and nav_file_name().

bool nav_file_isdir ( void  )

This function returns the type of selected file.

Returns
true, it is a directory
false, in other case

References fat_entry_is_dir().

Referenced by nav_file_copy(), ushell_cmd_ls(), and ushell_cmd_sync().

bool nav_file_isreadonly ( void  )

This function checks the write protection of disk and the Attribute "read only" of selected file.

Returns
false, it is possible to modify the selected file
true, in other case

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.

uint32_t nav_file_lgt ( void  )

This function returns the size of selected file (unit byte)

Returns
Size of selected file (unit byte)

References fs_g_nav_entry, and Fs_management_entry::u32_size.

Referenced by nav_file_paste_state(), and ushell_cmd_ls().

uint16_t nav_file_lgtsector ( void  )

This function returns the size of selected file (unit sector)

Returns
Size of selected file (unit 512B)

References FS_512B_SHIFT_BIT, fs_g_nav_entry, and Fs_management_entry::u32_size.

bool nav_file_name ( FS_STRING  sz_name,
uint8_t  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.

Parameters
b_modeaction mode:
FS_NAME_GET to get the name of selected file
FS_NAME_CHECK to check the name of selected file
sz_nameif 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_casefalse, ignore the case (only used in "FS_NAME_CHECK" action)
u8_size_maxstring size (unit ASCII or UNICODE ), only used in "FS_NAME_GET" action
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References _MEM_TYPE_SLOW_, 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 nav_dir_name(), nav_file_getname(), nav_filelist_findname(), nav_getcwd(), ushell_cmd_copy(), ushell_cmd_ls(), and ushell_cmd_sync().

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.

@param     sz_name     file name of the new file (ASCII or UNICODE )

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! After this routine, you shall called nav_file_paste_state() to run and way the copy
//! 

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 ushell_cmd_copy(), and ushell_cmd_sync().

uint8_t nav_file_paste_state ( bool  b_stop)
bool nav_file_rename ( const FS_STRING  sz_name)

This function renames the selected directory or file.

Parameters
sz_namenew name (ASCII or UNICODE )
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Referenced by ushell_cmd_rename().

bool nav_filelist_bol ( void  )

This function checks the beginning of file list.

Returns
false, it is not the beginning of file list
true, in case of the file selected is the first file, or in case of error

References FS_FIND_NEXT, FS_FIND_PREV, and nav_filelist_set().

bool nav_filelist_eol ( void  )

This function checks the end of file list.

Returns
false, NO end of file list
true, in case of end of list or error

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.

bool nav_filelist_exist ( bool  b_type)

This function checks the presence of files or directories in file list.

Parameters
b_typeFS_DIR to check the directory presence
FS_FILE to check the file presence
Returns
true, in case of a file or a directory exists
false, in case of no file or no directory exists, or error

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.

bool nav_filelist_fileisnotopen ( void  )

This function checks if no file is open.

Returns
true if no file is open
false if a file is open

References fat_check_noopen().

bool nav_filelist_findname ( const FS_STRING  sz_name,
bool  b_match_case 
)

This function searches a file name in file list.

@param     sz_name        name to search (UNICODE or ASCII) <br>
                          It must be terminate by NULL or '*' value
@param     b_match_case   false to ignore the case

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! This function starts a search at the next position of the current in file list
//! 

References FS_FIND_NEXT, FS_NAME_CHECK, nav_file_name(), and nav_filelist_set().

Referenced by nav_file_create(), and nav_setcwd().

bool nav_filelist_first ( bool  b_type)

This function goes to at the first file or directory in file list.

Parameters
b_typeFS_DIR to go at the first directory
FS_FILE to go at the first file
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

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 nav_filelist_exist(), and nav_filelist_last().

uint16_t nav_filelist_get ( void  )

This function returns the position of selected file in file list.

Returns
position of selected file (0 is the first position)
FS_NO_SEL, in case of no file selected

References fs_g_nav, and Fs_management::u16_pos_sel_file.

Referenced by nav_filelist_goto().

bool nav_filelist_goto ( uint16_t  u16_newpos)

This function goes at a position in file list.

Parameters
u16_newposnew position to select (0 is the first position)
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References FS_FIND_NEXT, FS_FIND_PREV, FS_NO_SEL, nav_filelist_get(), nav_filelist_reset(), and nav_filelist_set().

bool nav_filelist_last ( bool  b_type)

This function goes to at the last file or directory in file list.

Parameters
b_typeFS_DIR to go at the last directory
FS_FILE to go at the last file
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References FS_ERR_NO_FIND, FS_FIND_NEXT, fs_g_status, nav_filelist_first(), nav_filelist_nb(), and nav_filelist_set().

uint16_t nav_filelist_nb ( bool  b_type)

This function computes the number of files or directories in file list.

Parameters
b_typeFS_DIR to compute the number of directories
FS_FILE to compute the number of files
Returns
number of files or directories in file list

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 nav_filelist_last().

bool nav_filelist_reset ( void  )

This function resets the selection pointer, so "no file selected" in file list.

Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References fat_check_mount_noopen(), and fat_clear_entry_info_and_ptr().

Referenced by nav_dir_cd(), nav_dir_gotoparent(), nav_file_create(), nav_filelist_exist(), nav_filelist_first(), nav_filelist_goto(), nav_filelist_nb(), nav_filelist_single_disable(), nav_filelist_single_enable(), nav_gotoindex(), nav_setcwd(), ushell_cmd_ls(), and ushell_cmd_sync().

bool nav_filelist_set ( uint16_t  u16_nb,
bool  b_direction 
)

This function moves the selection pointer in file list.

@param     u16_nb      numbers of file to jump before stopping action <br>
                       0, stop at the first file found <br>
                       1, stop at the second file found <br>

@param     b_direction search direction <br>
                       FS_FIND_NEXT, move to next file or directory
                       FS_FIND_PREV, move to previous file or directory

@return  false in case of error, see global value "fs_g_status" for more detail
@return  true otherwise
//! Note: if no file is selected then nav_filelist_set( 0 , FS_NEXT ) goes to the first entry of the file list.
//! 

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 nav_dir_gotoparent(), 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_gotoindex(), ushell_cmd_ls(), and ushell_cmd_sync().

bool nav_filelist_single_disable ( void  )

To display in File List the directories AND files.

Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References Fs_management::b_mode_nav_single, fs_g_nav, and nav_filelist_reset().

bool nav_filelist_single_enable ( bool  b_type)

To display in File List only the files OR directories.

Parameters
b_typeFS_DIR to display only directories presence
FS_FILE to display only files presence
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References Fs_management::b_mode_nav, Fs_management::b_mode_nav_single, fs_g_nav, and nav_filelist_reset().

bool nav_filelist_validpos ( void  )

This function checks if a file is selected.

Returns
true if a file is selected
false if no file is selected

References fat_check_mount_select_noopen().

uint8_t nav_get ( void  )

This function returns the navigation identifier used.

Returns
u8_idnav navigator identifier selected

References fs_g_u8_nav_selected.

Referenced by nav_file_paste_start(), and nav_file_paste_state().

bool nav_getcwd ( FS_STRING  sz_path,
uint8_t  u8_size_path,
bool  b_view_file_select 
)

This function returns the full path of the selection.

Parameters
sz_pathstring to store the path (ASCII or UNICODE )
u8_size_pathstring size (unit ASCII or UNICODE )
b_view_file_selecttrue, to include in path the selected file name
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References _MEM_TYPE_SLOW_, 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().

Fs_index nav_getindex ( void  )

This function returns a small index on the selected file.

@return    It is a small index structure with information on selected file (disk, partition, dir, file/dir selected)
//! This routine is interesting to save a file position in small variable.
//! This pointer allow to reinit a navigator quickly with nav_gotoindex() routine.
//! 

References fs_g_nav, fs_g_nav_fast, Fs_index::u16_entry_pos_sel_file, Fs_management_fast::u16_entry_pos_sel_file, Fs_index::u32_cluster_sel_dir, Fs_management::u32_cluster_sel_dir, Fs_index::u8_lun, and Fs_management::u8_lun.

Referenced by nav_getcwd(), nav_partition_label(), nav_setcwd(), ushell_cmd_copy(), ushell_cmd_free_space(), ushell_cmd_mount(), ushell_cmd_perform(), ushell_cmd_rm(), ushell_cmd_sync(), and ushell_task().

bool nav_gotoindex ( const Fs_index _MEM_TYPE_SLOW_ index)

This function selects a file in the navigator via a file index.

@param     index       structure with information about file to select (disk, partition, dir, file/dir selected )

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! 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().
//! 

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 nav_getcwd(), nav_partition_label(), nav_setcwd(), ushell_cmd_copy(), ushell_cmd_free_space(), ushell_cmd_mount(), ushell_cmd_perform(), ushell_cmd_rm(), ushell_cmd_sync(), and ushell_task().

uint8_t nav_partition_cluster_size ( void  )

This function returns the partition cluster size.

Returns
cluster size (unit sector)

References fs_g_nav, and Fs_management::u8_BPB_SecPerClus.

uint32_t nav_partition_freespace ( void  )

This function returns the partition free space.

@return    number of free sectors
@return    0 in case of error or full partition
//! You shall mounted the partition before call this routine
//! 

References fat_check_device(), fat_getfreespace(), fs_g_nav_fast, FS_TYPE_FAT_UNM, and Fs_management_fast::u8_type_fat.

Referenced by ushell_cmd_free_space().

uint8_t nav_partition_freespace_percent ( void  )

This function returns the partition space free in percent.

@return    percent of free space (0% to 100%)
@return    0% in case of error or full partition
//! To speed up the compute, the result have an error delta of 1%
//! 

References fat_check_device(), fat_getfreespace_percent(), fs_g_nav_fast, FS_TYPE_FAT_UNM, and Fs_management_fast::u8_type_fat.

Referenced by ushell_cmd_free_space().

bool nav_partition_label ( bool  b_action,
FS_STRING  sz_label 
)

This function reads or writes the label of selected partition.

Parameters
b_actionto select the action
FS_LABEL_READ to read label
FS_LABEL_WRITE to write label
sz_labelpointer 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
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References _MEM_TYPE_SLOW_, 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.

bool nav_partition_mount ( void  )

This function mounts the selected partition.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  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
//! 

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 nav_dir_root(), nav_gotoindex(), nav_partition_type(), nav_setcwd(), ushell_cmd_free_space(), ushell_cmd_mount(), and ushell_cmd_perform_alloc().

bool nav_partition_serialnumber ( bool  b_action,
uint8_t _MEM_TYPE_SLOW_ a_u8_sn 
)

This function reads or writes the serial number on the selected partition.

Parameters
b_actionto select the action
FS_SN_READ to read serial number
FS_SN_WRITE to write serial number
a_u8_snpointer 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
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References fat_check_mount(), and fat_serialnumber().

uint32_t nav_partition_space ( void  )

This function returns partition total space.

@return    number of sectors
@return    0, in case of error
//! You shall mounted the partition before call this routine
//! 

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 ushell_cmd_free_space(), and ushell_cmd_space().

uint8_t nav_partition_type ( void  )

This function gives the partition type.

Returns
partition type: FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32
FS_TYPE_FAT_UNM, in case of error or unknown format

References fat_check_device(), fs_g_nav_fast, FS_TYPE_FAT_UNM, nav_partition_mount(), and Fs_management_fast::u8_type_fat.

Referenced by ushell_cmd_ls().

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)
//! 

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, and Fs_management_fast::u8_type_fat.

Referenced by ushell_task().

bool nav_select ( uint8_t  u8_idnav)

This function selects the navigation to use.

Parameters
u8_idnavnavigator identifier to select (0 to FS_NB_NAVIGATOR-1)
Returns
false if ID navigator don't exist
true otherwise

References fat_invert_nav(), FS_ERR_BAD_NAV, fs_g_status, fs_g_u8_nav_selected, and FS_NB_NAVIGATOR.

Referenced by nav_exit(), nav_file_paste_start(), nav_file_paste_state(), nav_reset(), ushell_cmd_perform(), ushell_cmd_sync(), and ushell_task().

bool nav_setcwd ( FS_STRING  sz_path,
bool  b_match_case,
bool  b_create 
)

This function selects a disk position via a path.

@param     sz_path           path string (ASCII or UNICODE )
@param     b_match_case      false to ignore the case
@param     b_create          true, if path does not exist then create it <br>
                             false, no create path <br>

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! The syntax "./../../file_name" is supported.
//! With syntax "./dir_parent/directory_name"  the file list corresponding at "dir_parent" and "directory_name" is selected.
//! With syntax "./dir_parent/directory_name/" the file list corresponding at "directory_name" and no file is selected.
//! 

References _MEM_TYPE_SLOW_, 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 ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_cd(), ushell_cmd_copy(), ushell_cmd_rename(), ushell_cmd_rm(), and ushell_cmd_sync().

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.
//! 

References g_b_string_length.

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.
//! 

References g_b_string_length.

_MEM_TYPE_SLOW_ uint8_t fs_g_u8_nav_selected

Holds the current navigator selected.

Referenced by nav_copy(), nav_get(), nav_reset(), and nav_select().

_MEM_TYPE_SLOW_ uint8_t g_id_trans_memtomem = ID_STREAM_ERR

Holds the current ID transfer used by the internal copy-paste routines.

Referenced by nav_file_paste_start(), and nav_file_paste_state().