ASF docs  3.1.3
Some important library documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
navigation.c File Reference
#include <ctype.h>
#include "conf_explorer.h"
#include "navigation.h"
#include "file.h"
#include <LIB_CTRLACCESS>
+ Include dependency graph for navigation.c:

Go to the source code of this file.

Macros

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

Functions

void nav_string_unicode (void)
 This function selects the UNICODE mode for all routines with FS_STRING parameter.
void nav_string_ascii (void)
 This function selects the ASCII 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_length_disable (void)
 This function deselects the LENGTH string mode for all routines with FS_STRING parameter.
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.
void nav_reset (void)
 This function resets ALL navigations to init file system core.
void nav_exit (void)
 This function flush ALL navigations before exit of file system core.
bool nav_select (uint8_t u8_idnav)
 This function selects the navigation to use.
uint8_t nav_get (void)
 This function returns the navigation identifier used.
bool nav_copy (uint8_t u8_idnav)
 This function copys the navigator information to another navigator.
uint8_t nav_drive_nb (void)
 This function returns the number of devices availabled.
bool nav_drive_set (uint8_t u8_number)
 This function selects a drive in navigator but don't mount the disk partition.
uint8_t nav_drive_get (void)
 This function returns the selected drive number.
uint8_t nav_drive_getname (void)
 This function returns the selected drive letter.
uint8_t nav_partition_nb (void)
 This function returns the number of partitions present on drive.
bool nav_partition_set (uint8_t partition_number)
 This function selects a partition on drive.
bool nav_partition_mount (void)
 This function mounts the selected partition.
uint8_t nav_partition_type (void)
 This function gives the partition type.
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.
bool nav_partition_label (bool b_action, FS_STRING sz_label)
 This function reads or writes the label of selected partition.
uint32_t nav_partition_space (void)
 This function returns partition total space.
uint8_t nav_partition_cluster_size (void)
 This function returns the partition cluster size.
uint32_t nav_partition_freespace (void)
 This function returns the partition free space.
uint8_t nav_partition_freespace_percent (void)
 This function returns the partition space free in percent.
bool nav_filelist_single_enable (bool b_type)
 To display in File List only the files OR directories.
bool nav_filelist_single_disable (void)
 To display in File List the directories AND files.
bool nav_filelist_reset (void)
 This function resets the selection pointer, so "no file selected" in file list.
bool nav_filelist_validpos (void)
 This function checks if a file is selected.
bool nav_filelist_fileisnotopen (void)
 This function checks if no file is open.
bool nav_filelist_set (uint16_t u16_nb, bool b_direction)
 This function moves the selection pointer in file list.
uint16_t nav_filelist_get (void)
 This function returns the position of selected file in file list.
bool nav_filelist_goto (uint16_t u16_newpos)
 This function goes at a position in file list.
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_eol (void)
 This function checks the end of file list.
bool nav_filelist_bol (void)
 This function checks the beginning of file list.
bool nav_filelist_exist (bool b_type)
 This function checks the presence of files or directories in file list.
uint16_t nav_filelist_nb (bool b_type)
 This function computes the number of files or directories in file list.
bool nav_filelist_first (bool b_type)
 This function goes to at the first file or directory in file list.
bool nav_filelist_last (bool b_type)
 This function goes to at the last file or directory in file list.
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.
bool nav_dir_root (void)
 This function initializes the file list on the root directory.
bool nav_dir_is_root (void)
 This function check the current directory.
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_name (FS_STRING sz_path, uint8_t u8_size_max)
 This function returns the directory name corresponding at the file list.
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.
bool nav_setcwd (FS_STRING sz_path, bool b_match_case, bool b_create)
 This function selects a disk position via a path.
bool nav_file_getname (FS_STRING sz_name, uint8_t u8_size_max)
 This function returns the name of selected file.
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.
uint32_t nav_file_lgt (void)
 This function returns the size of selected file (unit byte)
uint16_t nav_file_lgtsector (void)
 This function returns the size of selected file (unit sector)
bool nav_file_isreadonly (void)
 This function checks the write protection of disk and the attribut "read only" of selected file.
bool nav_file_isdir (void)
 This function returns the type of selected file.
bool nav_file_checkext (const FS_STRING sz_filterext)
 This function checks the extension of selected file.
bool nav_file_dateget (FS_STRING sz_date, bool type_date)
 This function returns the date of selected file.
uint8_t nav_file_attributget (void)
 This function returns the attribut of selected file.

Macro Definition Documentation

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

Definition at line 75 of file navigation.c.


Function Documentation

void nav_checkdisk_disable ( void  )
//! 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 140 of file navigation.c.

void nav_checkdisk_enable ( void  )
//! 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 152 of file navigation.c.

bool nav_copy ( uint8_t  u8_idnav)
Parameters:
u8_idnavnavigator identifier where the main navigator will be copied
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise
//! Use this routine to select quickly the same file in another navigator
//! 

Definition at line 284 of file navigation.c.

bool nav_dir_cd ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
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 1192 of file navigation.c.

bool nav_dir_gotoparent ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
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 1222 of file navigation.c.

bool nav_dir_is_root ( void  )
Returns:
false the current directory selected is not the root directory
true the current directory selected is the root directory

Definition at line 1173 of file navigation.c.

bool nav_dir_name ( FS_STRING  sz_path,
uint8_t  u8_size_max 
)
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

Definition at line 1270 of file navigation.c.

bool nav_dir_root ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 1162 of file navigation.c.

uint8_t nav_drive_get ( void  )
Returns:
0 to nav_drive_nb()-1
0xFF in case of no drive selected

Definition at line 356 of file navigation.c.

uint8_t nav_drive_getname ( void  )
Returns:
'A','B',...
'X', in case of no drive selected

Definition at line 373 of file navigation.c.

uint8_t nav_drive_nb ( void  )
Returns:
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)
//! 

Definition at line 314 of file navigation.c.

bool nav_drive_set ( uint8_t  u8_number)
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

Definition at line 327 of file navigation.c.

void nav_exit ( void  )
//! Call this at the program exit or before a USB Device session
//! 

Definition at line 214 of file navigation.c.

uint8_t nav_file_attributget ( void  )
Returns:
attribut of selected file, see masks "FS_ATTR_" in fs_com.h file.

Definition at line 1951 of file navigation.c.

bool nav_file_checkext ( const FS_STRING  sz_filterext)
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

Definition at line 1908 of file navigation.c.

bool nav_file_dateget ( FS_STRING  sz_date,
bool  type_date 
)
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, seconde, miliseconde
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 1934 of file navigation.c.

bool nav_file_getname ( FS_STRING  sz_name,
uint8_t  u8_size_max 
)
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

Definition at line 1751 of file navigation.c.

bool nav_file_isdir ( void  )
Returns:
true, it is a directory
false, in other case

Definition at line 1895 of file navigation.c.

bool nav_file_isreadonly ( void  )
Returns:
false, it is possible to modify the selected file
true, in other case

Definition at line 1880 of file navigation.c.

uint32_t nav_file_lgt ( void  )
Returns:
Size of selected file (unit byte)

Definition at line 1859 of file navigation.c.

uint16_t nav_file_lgtsector ( void  )
Returns:
Size of selected file (unit 512B)

Definition at line 1869 of file navigation.c.

bool nav_file_name ( FS_STRING  sz_name,
uint8_t  u8_size_max,
bool  b_mode,
bool  b_match_case 
)
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

Definition at line 1772 of file navigation.c.

bool nav_filelist_bol ( void  )
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

Definition at line 950 of file navigation.c.

bool nav_filelist_eol ( void  )
Returns:
false, NO end of file list
true, in case of end of list or error

Definition at line 926 of file navigation.c.

bool nav_filelist_exist ( bool  b_type)
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

Definition at line 968 of file navigation.c.

bool nav_filelist_fileisnotopen ( void  )
Returns:
true if no file is open
false if a file is open

Definition at line 706 of file navigation.c.

bool nav_filelist_findname ( const FS_STRING  sz_name,
bool  b_match_case 
)
Parameters:
sz_namename to search (UNICODE or ASCII)
It must be terminate by NULL or '*' value
b_match_casefalse to ignore the case
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise
//! This function starts a search at the next position of the current in file list
//! 

Definition at line 909 of file navigation.c.

bool nav_filelist_first ( bool  b_type)
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

Definition at line 1037 of file navigation.c.

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

Definition at line 849 of file navigation.c.

bool nav_filelist_goto ( uint16_t  u16_newpos)
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

Definition at line 862 of file navigation.c.

bool nav_filelist_last ( bool  b_type)
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

Definition at line 1061 of file navigation.c.

uint16_t nav_filelist_nb ( bool  b_type)
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

Definition at line 994 of file navigation.c.

bool nav_filelist_reset ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 679 of file navigation.c.

bool nav_filelist_set ( uint16_t  u16_nb,
bool  b_direction 
)
Parameters:
u16_nbnumbers of file to jump before stopping action
0, stop at the first file found
1, stop at the second file found
b_directionsearch direction
FS_FIND_NEXT, move to next file or directory FS_FIND_PREV, move to previous file or directory
Returns:
false in case of error, see global value "fs_g_status" for more detail
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 729 of file navigation.c.

bool nav_filelist_single_disable ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 667 of file navigation.c.

bool nav_filelist_single_enable ( bool  b_type)
Parameters:
b_typeFS_DIR to display only directories presence
FS_FILE to dispaly only files presence
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 651 of file navigation.c.

bool nav_filelist_validpos ( void  )
Returns:
true if a file is selected
false if no file is selected

Definition at line 695 of file navigation.c.

uint8_t nav_get ( void  )
Returns:
u8_idnav navigator identifier selected

Definition at line 263 of file navigation.c.

bool nav_getcwd ( FS_STRING  sz_path,
uint8_t  u8_size_path,
bool  b_view_file_select 
)
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

Definition at line 1414 of file navigation.c.

Fs_index nav_getindex ( void  )
Returns:
It is a small index structure with information on selected file (disk, partition, dir, file/dir selected)
//! 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 1096 of file navigation.c.

bool nav_gotoindex ( const Fs_index _MEM_TYPE_SLOW_ *  index)
Parameters:
indexstructure with information about file to select (disk, partition, dir, file/dir selected )
Returns:
false in case of error, see global value "fs_g_status" for more detail
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 1123 of file navigation.c.

uint8_t nav_partition_cluster_size ( void  )
Returns:
cluster size (unit sector)

Definition at line 598 of file navigation.c.

uint32_t nav_partition_freespace ( void  )
Returns:
number of free sectors
0 in case of error or full partition
//! You shall mounted the partition before call this routine
//! 

Definition at line 612 of file navigation.c.

uint8_t nav_partition_freespace_percent ( void  )
Returns:
percent of free space (0% to 100%)
0% in case of error or full partition
//! To speed up the compute, the resultat have an error delta of 1%
//! 

Definition at line 630 of file navigation.c.

bool nav_partition_label ( bool  b_action,
FS_STRING  sz_label 
)
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

Definition at line 532 of file navigation.c.

bool nav_partition_mount ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
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 464 of file navigation.c.

uint8_t nav_partition_nb ( void  )
Returns:
u8_number number of partitions

Definition at line 424 of file navigation.c.

bool nav_partition_serialnumber ( bool  b_action,
uint8_t _MEM_TYPE_SLOW_ *  a_u8_sn 
)
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

Definition at line 511 of file navigation.c.

bool nav_partition_set ( uint8_t  partition_number)
Parameters:
partition_numberpartition number (0 to 3)
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 437 of file navigation.c.

uint32_t nav_partition_space ( void  )
Returns:
number of sectors
0, in case of error
//! You shall mounted the partition before call this routine
//! 

Definition at line 585 of file navigation.c.

uint8_t nav_partition_type ( void  )
Returns:
partition type: FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32
FS_TYPE_FAT_UNM, in case of error or unknow format

Definition at line 488 of file navigation.c.

void nav_reset ( void  )
//! Call this at the program startup or before a new session (e.g. USB Device exit)
//! 

Definition at line 168 of file navigation.c.

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

Definition at line 240 of file navigation.c.

bool nav_setcwd ( FS_STRING  sz_path,
bool  b_match_case,
bool  b_create 
)
Parameters:
sz_pathpath string (ASCII or UNICODE )
b_match_casefalse to ignore the case
b_createtrue, if path does not exist then create it
false, no create path
Returns:
false in case of error, see global value "fs_g_status" for more detail
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 1581 of file navigation.c.

void nav_string_ascii ( void  )
//! 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 101 of file navigation.c.

void nav_string_length_disable ( void  )
//! 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 125 of file navigation.c.

void nav_string_length_enable ( void  )
//! 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 114 of file navigation.c.

void nav_string_unicode ( void  )
//! 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 90 of file navigation.c.