Microchip® Advanced Software Framework

fs_com.h File Reference
#include "conf_explorer.h"

Data Structures

struct  Fs_index
 

Macros

#define _GLOBEXT_   extern
 Used to have a clear code with only one segment to define a variable in project. More...
 
Modes of file name control functions
#define FS_NAME_GET   true
 
#define FS_NAME_CHECK   false
 
Modes of disk serial number function
#define FS_SN_READ   true
 
#define FS_SN_WRITE   false
 
Modes of disk label function
#define FS_LABEL_READ   true
 
#define FS_LABEL_WRITE   false
 
Status returned by paste file function
#define COPY_BUSY   0x00
 
#define COPY_FAIL   0x01
 
#define COPY_FINISH   0x02
 
Date field managed by date control functions
#define FS_DATE_CREATION   true
 
#define FS_DATE_LAST_WRITE   false
 
File entry types used by many functions
#define FS_FILE   true
 
#define FS_DIR   false
 
Directory identifier, which corresponding at the first cluster of directory cluster list
#define FS_ID_DIR_EMPTY   0xFFFFFFFF
 
#define FS_ID_DIR_ROOT   0
 
File entry attributes
#define FS_ATTR_FILE   ((Byte)0x00)
 
#define FS_ATTR_READ_ONLY   ((Byte)0x01)
 
#define FS_ATTR_HIDDEN   ((Byte)0x02)
 
#define FS_ATTR_SYSTEM   ((Byte)0x04)
 
#define FS_ATTR_VOLUME_ID   ((Byte)0x08)
 
#define FS_ATTR_DIRECTORY   ((Byte)0x10)
 
#define FS_ATTR_ARCHIVE   ((Byte)0x20)
 
#define FS_ATTR_LFN_ENTRY   ((Byte)0x0F)
 
#define Fat_is_not_a_file   ((FS_ATTR_DIRECTORY & fs_g_nav_entry.u8_attr) || (FS_ATTR_VOLUME_ID & fs_g_nav_entry.u8_attr))
 
File open modes
#define FOPEN_READ_ACCESS   0x01
 
#define FOPEN_WRITE_ACCESS   0x02
 
#define FOPEN_CLEAR_SIZE   0x04
 
#define FOPEN_CLEAR_PTR   0x08
 
#define FOPEN_MODE_R   (FOPEN_READ_ACCESS|FOPEN_CLEAR_PTR)
 R access, flux pointer = 0, size not modify. More...
 
#define FOPEN_MODE_R_PLUS   (FOPEN_READ_ACCESS|FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR)
 R/W access, flux pointer = 0, size not modify. More...
 
#define FOPEN_MODE_W   (FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR|FOPEN_CLEAR_SIZE)
 W access, flux pointer = 0, size = 0. More...
 
#define FOPEN_MODE_W_PLUS   (FOPEN_READ_ACCESS|FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR|FOPEN_CLEAR_SIZE)
 R/W access, flux pointer = 0, size = 0. More...
 
#define FOPEN_MODE_APPEND   (FOPEN_WRITE_ACCESS)
 W access, flux pointer = at the end, size not modify. More...
 
Value to signal the end of file after a file_getc() call
#define FS_EOF   0xFFFF
 
Options of format function
#define FS_FORMAT_DEFAULT   0x01
 The format routine chooses the better FAT for the device. More...
 
#define FS_FORMAT_FAT   0x02
 Force FAT12 or FAT16 format. More...
 
#define FS_FORMAT_FAT32   0x03
 Force FAT32 format. More...
 
#define FS_FORMAT_NOMBR_FLAG   0x80
 MBR is mandatory for USB device on MacOS, and no MBR is mandatory for CD-ROM USB device on Windows. More...
 
#define FS_FORMAT_DEFAULT_NOMBR   (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_DEFAULT)
 
#define FS_FORMAT_FAT_NOMBR   (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_FAT)
 
#define FS_FORMAT_FAT32_NOMBR   (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_FAT32)
 
File System errors list
#define FS_ERR_HW   (FAIL+0)
 Hardware driver error. More...
 
#define FS_ERR_NO_FORMAT   (FAIL+1)
 The selected drive isn't formated. More...
 
#define FS_ERR_NO_PART   (FAIL+2)
 The selected partition doesn't existed. More...
 
#define FS_ERR_NO_SUPPORT_PART   (FAIL+3)
 The selected partition isn't supported. More...
 
#define FS_ERR_TOO_FILE_OPEN   (FAIL+4)
 The navigation have already opened a file. More...
 
#define FS_ERR_END_OF_DRIVE   (FAIL+5)
 There are not other driver. More...
 
#define FS_ERR_BAD_POS   (FAIL+6)
 The position is over the file. More...
 
#define FS_ERR_FS   (FAIL+7)
 File system error. More...
 
#define FS_ERR_NO_FIND   (FAIL+8)
 File no found. More...
 
#define FS_ERR_ENTRY_EMPTY   (FAIL+9)
 File entry empty. More...
 
#define FS_ERR_ENTRY_BAD   (FAIL+10)
 File entry bad. More...
 
#define FS_ERR_ENTRY_BADTYPE   (FAIL+11)
 File entry type don't corresponding. More...
 
#define FS_ERR_NO_DIR   (FAIL+12)
 The selected file isn't a directory. More...
 
#define FS_ERR_NO_MOUNT   (FAIL+13)
 The partition isn't mounted. More...
 
#define FS_ERR_NO_FILE_SEL   (FAIL+14)
 There are no selected file. More...
 
#define FS_NO_LAST_LFN_ENTRY   (FAIL+15)
 The file entry isn't the last long file entry. More...
 
#define FS_ERR_ID_FILE   (FAIL+17)
 The file identifier is bad. More...
 
#define FS_ERR_NO_FILE   (FAIL+18)
 The selected file entry isn't a file. More...
 
#define FS_LUN_WP   (FAIL+19)
 Drive is in read only mode. More...
 
#define FS_ERR_READ_ONLY   (FAIL+20)
 File is on read access only. More...
 
#define FS_ERR_NAME_INCORRECT   (FAIL+21)
 The name don't corresponding at the filter name. More...
 
#define FS_ERR_FILE_NO_OPEN   (FAIL+22)
 No file is opened. More...
 
#define FS_ERR_HW_NO_PRESENT   (FAIL+23)
 Device is not present. More...
 
#define FS_ERR_IS_ROOT   (FAIL+24)
 There aren't parent because the current directory is a root directory. More...
 
#define FS_ERR_OUT_LIST   (FAIL+25)
 The position is outside the cluster list. More...
 
#define FS_ERR_NO_FREE_SPACE   (FAIL+26)
 No free cluster found in FAT. More...
 
#define FS_ERR_INCORRECT_NAME   (FAIL+27)
 Incorrect name, this one cannot contain any of the following characters \/:*?"<>|. More...
 
#define FS_ERR_DIR_NOT_EMPTY   (FAIL+28)
 This function erases only file and empty directory. More...
 
#define FS_ERR_WRITE_ONLY   (FAIL+29)
 File is on write access only. More...
 
#define FS_ERR_MODE_NOAVIALABLE   (FAIL+30)
 This open mode isn't available. More...
 
#define FS_ERR_EOF   (FAIL+31)
 End of file. More...
 
#define FS_ERR_BAD_SIZE_FAT   (FAIL+32)
 The disk size is not supported by selected FAT format. More...
 
#define FS_ERR_COMMAND   (FAIL+33)
 This command is not supported. More...
 
#define FS_ERR_BUFFER_FULL   (FAIL+34)
 Buffer is too small. More...
 
#define FS_ERR_COPY_DIR   (FAIL+35)
 Directory copy is not supported. More...
 
#define FS_ERR_COPY_RUNNING   (FAIL+36)
 A copy action is always running. More...
 
#define FS_ERR_COPY_IMPOSSIBLE   (FAIL+37)
 The copy is impossible. More...
 
#define FS_ERR_BAD_NAV   (FAIL+38)
 The navigator identifier doesn't existed. More...
 
#define FS_ERR_FILE_OPEN   (FAIL+39)
 The file is already opened. More...
 
#define FS_ERR_FILE_OPEN_WR   (FAIL+40)
 The file is already opened in write mode. More...
 
#define FS_ERR_FILE_EXIST   (FAIL+41)
 The file is already existed. More...
 
#define FS_ERR_NAME_TOO_LARGE   (FAIL+42)
 The file name is too large (>260 characters) More...
 
#define FS_ERR_DEVICE_TOO_SMALL   (FAIL+43)
 The disk size is too small for format routine. More...
 
#define FS_ERR_PL_NOT_OPEN   (FAIL+50)
 The play list isn't opened. More...
 
#define FS_ERR_PL_ALREADY_OPEN   (FAIL+51)
 The play list is already opened. More...
 
#define FS_ERR_PL_LST_END   (FAIL+52)
 You are at the end of play list. More...
 
#define FS_ERR_PL_LST_BEG   (FAIL+53)
 You are at the beginning of play list. More...
 
#define FS_ERR_PL_OUT_LST   (FAIL+54)
 You are outside of the play list. More...
 
#define FS_ERR_PL_READ_ONLY   (FAIL+55)
 Impossible to modify the play list. More...
 
Compilation feature levels
#define FSFEATURE_READ   0x00
 All read functions. More...
 
#define FSFEATURE_WRITE   0x02
 nav_file_copy(), nav_file_paste(), nav_file_del(), file_create(), file_open(MODE_WRITE), file_write(), file_putc() More...
 
#define FSFEATURE_WRITE_COMPLET   0x06
 FSFEATURE_WRITE + nav_drive_format(), nav_dir_make(), nav_file_rename(), nav_file_dateset(), nav_file_attributset() More...
 
#define FSFEATURE_ALL   0xFF
 All file system module. More...
 

Typedefs

String types depend of ASCII and UNICODE options
typedef uint16_t UNICODE
 
typedef char _MEM_TYPE_SLOW_FS_STRING
 
typedef UNICODE _MEM_TYPE_SLOW_FS_STR_UNICODE
 
Status type for the file system
typedef uint8_t Fs_status
 

Variables

Global status of file system module (used to return error number)
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_status fs_g_status
 

#define _GLOBEXT_   extern

Used to have a clear code with only one segment to define a variable in project.

#define COPY_BUSY   0x00
#define COPY_FAIL   0x01
#define COPY_FINISH   0x02
#define Fat_is_not_a_file   ((FS_ATTR_DIRECTORY & fs_g_nav_entry.u8_attr) || (FS_ATTR_VOLUME_ID & fs_g_nav_entry.u8_attr))

Referenced by fat_check_is_file().

#define FOPEN_CLEAR_PTR   0x08

Referenced by file_open().

#define FOPEN_CLEAR_SIZE   0x04

Referenced by file_open().

#define FOPEN_MODE_APPEND   (FOPEN_WRITE_ACCESS)

W access, flux pointer = at the end, size not modify.

Referenced by ushell_cmd_append_file().

#define FOPEN_MODE_R   (FOPEN_READ_ACCESS|FOPEN_CLEAR_PTR)

R access, flux pointer = 0, size not modify.

Referenced by nav_file_paste_start(), and ushell_cmd_cat().

#define FOPEN_MODE_R_PLUS   (FOPEN_READ_ACCESS|FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR)

R/W access, flux pointer = 0, size not modify.

W access, flux pointer = 0, size = 0.

Referenced by ushell_cmd_perform_alloc().

R/W access, flux pointer = 0, size = 0.

Referenced by nav_file_paste_start().

#define FOPEN_READ_ACCESS   0x01

Referenced by file_getc(), file_read(), and file_read_buf().

#define FOPEN_WRITE_ACCESS   0x02
#define FS_ATTR_ARCHIVE   ((Byte)0x20)
#define FS_ATTR_DIRECTORY   ((Byte)0x10)
#define FS_ATTR_FILE   ((Byte)0x00)
#define FS_ATTR_HIDDEN   ((Byte)0x02)
#define FS_ATTR_LFN_ENTRY   ((Byte)0x0F)
#define FS_ATTR_READ_ONLY   ((Byte)0x01)

Referenced by file_open(), and nav_file_isreadonly().

#define FS_ATTR_SYSTEM   ((Byte)0x04)
#define FS_ATTR_VOLUME_ID   ((Byte)0x08)

Referenced by fat_entry_check(), and fat_entry_label().

#define FS_DATE_CREATION   true
#define FS_DATE_LAST_WRITE   false

Referenced by fat_get_date().

#define FS_EOF   0xFFFF

Referenced by file_getc().

#define FS_ERR_BAD_NAV   (FAIL+38)

The navigator identifier doesn't existed.

Referenced by nav_select().

#define FS_ERR_BAD_POS   (FAIL+6)

The position is over the file.

Referenced by file_seek().

#define FS_ERR_BAD_SIZE_FAT   (FAIL+32)

The disk size is not supported by selected FAT format.

Referenced by fat_select_filesystem().

#define FS_ERR_BUFFER_FULL   (FAIL+34)

Buffer is too small.

Referenced by nav_getcwd().

#define FS_ERR_COMMAND   (FAIL+33)

This command is not supported.

Referenced by fat_cluster_val().

#define FS_ERR_COPY_DIR   (FAIL+35)

Directory copy is not supported.

Referenced by nav_file_copy().

#define FS_ERR_COPY_IMPOSSIBLE   (FAIL+37)

The copy is impossible.

#define FS_ERR_COPY_RUNNING   (FAIL+36)

A copy action is always running.

Referenced by nav_file_paste_start().

#define FS_ERR_DEVICE_TOO_SMALL   (FAIL+43)

The disk size is too small for format routine.

Referenced by fat_select_filesystem().

#define FS_ERR_DIR_NOT_EMPTY   (FAIL+28)

This function erases only file and empty directory.

#define FS_ERR_END_OF_DRIVE   (FAIL+5)

There are not other driver.

Referenced by nav_drive_set().

#define FS_ERR_ENTRY_BAD   (FAIL+10)
#define FS_ERR_ENTRY_BADTYPE   (FAIL+11)

File entry type don't corresponding.

#define FS_ERR_EOF   (FAIL+31)

End of file.

Referenced by file_getc(), file_read(), and file_read_buf().

#define FS_ERR_FILE_EXIST   (FAIL+41)

The file is already existed.

Referenced by nav_file_create(), ushell_cmd_perform_alloc(), and ushell_cmd_sync().

#define FS_ERR_FILE_NO_OPEN   (FAIL+22)

No file is opened.

Referenced by fat_check_open().

#define FS_ERR_FILE_OPEN   (FAIL+39)

The file is already opened.

Referenced by fat_check_nav_access_file().

#define FS_ERR_FILE_OPEN_WR   (FAIL+40)

The file is already opened in write mode.

Referenced by fat_check_nav_access_file().

#define FS_ERR_FS   (FAIL+7)

File system error.

Referenced by fat_cluster_list(), nav_dir_gotoparent(), and nav_filelist_set().

#define FS_ERR_HW   (FAIL+0)
#define FS_ERR_HW_NO_PRESENT   (FAIL+23)

Device is not present.

Referenced by fat_check_device().

#define FS_ERR_ID_FILE   (FAIL+17)

The file identifier is bad.

#define FS_ERR_INCORRECT_NAME   (FAIL+27)

Incorrect name, this one cannot contain any of the following characters \/:*?"<>|.

Referenced by fat_check_name().

#define FS_ERR_IS_ROOT   (FAIL+24)

There aren't parent because the current directory is a root directory.

Referenced by nav_dir_gotoparent(), and nav_getcwd().

#define FS_ERR_MODE_NOAVIALABLE   (FAIL+30)

This open mode isn't available.

Referenced by file_open().

#define FS_ERR_NAME_INCORRECT   (FAIL+21)

The name don't corresponding at the filter name.

Referenced by fat_entry_label(), fat_entry_longname(), and fat_entry_shortname().

#define FS_ERR_NAME_TOO_LARGE   (FAIL+42)

The file name is too large (>260 characters)

Referenced by fat_check_name().

#define FS_ERR_NO_DIR   (FAIL+12)

The selected file isn't a directory.

Referenced by fat_entry_is_dir(), and ushell_cmd_sync().

#define FS_ERR_NO_FILE   (FAIL+18)

The selected file entry isn't a file.

Referenced by fat_check_is_file().

#define FS_ERR_NO_FILE_SEL   (FAIL+14)

There are no selected file.

Referenced by fat_check_select().

#define FS_ERR_NO_FIND   (FAIL+8)

File no found.

Referenced by nav_filelist_first(), nav_filelist_last(), and nav_filelist_set().

#define FS_ERR_NO_FORMAT   (FAIL+1)

The selected drive isn't formated.

Referenced by fat_mount().

#define FS_ERR_NO_FREE_SPACE   (FAIL+26)

No free cluster found in FAT.

Referenced by fat_alloc_entry_free().

#define FS_ERR_NO_MOUNT   (FAIL+13)

The partition isn't mounted.

Referenced by fat_check_mount().

#define FS_ERR_NO_PART   (FAIL+2)

The selected partition doesn't existed.

Referenced by fat_mount().

#define FS_ERR_NO_SUPPORT_PART   (FAIL+3)

The selected partition isn't supported.

Referenced by fat_mount().

#define FS_ERR_OUT_LIST   (FAIL+25)
#define FS_ERR_PL_ALREADY_OPEN   (FAIL+51)

The play list is already opened.

#define FS_ERR_PL_LST_BEG   (FAIL+53)

You are at the beginning of play list.

#define FS_ERR_PL_LST_END   (FAIL+52)

You are at the end of play list.

#define FS_ERR_PL_NOT_OPEN   (FAIL+50)

The play list isn't opened.

#define FS_ERR_PL_OUT_LST   (FAIL+54)

You are outside of the play list.

#define FS_ERR_PL_READ_ONLY   (FAIL+55)

Impossible to modify the play list.

#define FS_ERR_READ_ONLY   (FAIL+20)

File is on read access only.

Referenced by file_open(), file_putc(), file_set_eof(), and file_write_buf().

#define FS_ERR_TOO_FILE_OPEN   (FAIL+4)

The navigation have already opened a file.

Referenced by fat_check_noopen().

#define FS_ERR_WRITE_ONLY   (FAIL+29)

File is on write access only.

Referenced by file_getc(), file_read(), and file_read_buf().

#define FS_FORMAT_DEFAULT   0x01

The format routine chooses the better FAT for the device.

Referenced by ushell_cmd_format().

#define FS_FORMAT_DEFAULT_NOMBR   (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_DEFAULT)
#define FS_FORMAT_FAT   0x02

Force FAT12 or FAT16 format.

Referenced by fat_select_filesystem().

#define FS_FORMAT_FAT32   0x03

Force FAT32 format.

Referenced by fat_select_filesystem().

#define FS_FORMAT_FAT32_NOMBR   (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_FAT32)
#define FS_FORMAT_FAT_NOMBR   (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_FAT)
#define FS_FORMAT_NOMBR_FLAG   0x80

MBR is mandatory for USB device on MacOS, and no MBR is mandatory for CD-ROM USB device on Windows.

Referenced by fat_format().

#define FS_ID_DIR_EMPTY   0xFFFFFFFF
#define FS_ID_DIR_ROOT   0
#define FS_LABEL_READ   true
#define FS_LABEL_WRITE   false
#define FS_LUN_WP   (FAIL+19)

Drive is in read only mode.

Referenced by fat_cache_flush(), and file_open().

#define FS_NAME_CHECK   false

Referenced by nav_filelist_findname().

#define FS_NO_LAST_LFN_ENTRY   (FAIL+15)

The file entry isn't the last long file entry.

Referenced by fat_entry_longname(), and nav_file_name().

#define FS_SN_READ   true

Referenced by fat_serialnumber().

#define FS_SN_WRITE   false
#define FSFEATURE_ALL   0xFF

All file system module.

#define FSFEATURE_READ   0x00

All read functions.

#define FSFEATURE_WRITE   0x02

nav_file_copy(), nav_file_paste(), nav_file_del(), file_create(), file_open(MODE_WRITE), file_write(), file_putc()

#define FSFEATURE_WRITE_COMPLET   0x06

typedef uint8_t Fs_status
typedef char _MEM_TYPE_SLOW_* FS_STRING
typedef uint16_t UNICODE