#include "conf_explorer.h"
#include "file.h"
#include "navigation.h"
#include <string.h>
#include "ctrl_access.h"
Functions | |
uint8_t | file_bof (void) |
This function checks the beginning of file. More... | |
void | file_close (void) |
This function closes the file. More... | |
uint8_t | file_eof (void) |
This function checks the end of file. More... | |
void | file_flush (void) |
This function flushes the internal cache (file data and file information) More... | |
uint16_t | file_getc (void) |
This function returns the next byte of file. More... | |
uint32_t | file_getpos (void) |
This function returns the position in the file. More... | |
bool | file_ispresent (void) |
This function checks if a file is selected. More... | |
static void | file_load_segment_value (Fs_file_segment _MEM_TYPE_SLOW_ *segment) |
This function stores the global segment variable in other variable. More... | |
bool | file_open (uint8_t fopen_mode) |
This function opens the selected file. More... | |
bool | file_putc (uint8_t u8_byte) |
This function writes a byte in the file. More... | |
bool | file_read (Fs_file_segment _MEM_TYPE_SLOW_ *segment) |
This function returns a segment (position & size) in a physical memory corresponding at the file. More... | |
uint16_t | file_read_buf (uint8_t _MEM_TYPE_SLOW_ *buffer, uint16_t u16_buf_size) |
This function copies in a buffer the file data corresponding at the current position. More... | |
bool | file_seek (uint32_t u32_pos, uint8_t u8_whence) |
This function changes the position in the file. More... | |
bool | file_set_eof (void) |
This function sets the end of file at the current position. More... | |
bool | file_write (Fs_file_segment _MEM_TYPE_SLOW_ *segment) |
This function allocs and returns a segment (position & size) in a physical memory corresponding at the file. More... | |
uint16_t | file_write_buf (uint8_t _MEM_TYPE_SLOW_ *buffer, uint16_t u16_buf_size) |
This function transfer a buffer to a file at the current file position. More... | |
Variables | |
_MEM_TYPE_SLOW_ uint8_t | fs_g_sector [FS_CACHE_SIZE] |
Use "FAT sector cache" to store a sector from a file (see file_putc(), file_getc(), file_read_buf(), file_write_buf()) More... | |
uint8_t file_bof | ( | void | ) |
This function checks the beginning of file.
References fat_check_mount_select_open(), fs_g_nav_entry, and Fs_management_entry::u32_pos_in_file.
void file_close | ( | void | ) |
This function closes the file.
References fat_cache_flush(), fat_check_mount_select_open(), Fat_file_close, fat_read_dir(), fat_write_entry_file(), FOPEN_WRITE_ACCESS, fs_g_nav_entry, and Fs_management_entry::u8_open_mode.
Referenced by close(), file_flush(), nav_exit(), nav_file_paste_start(), and nav_file_paste_state().
uint8_t file_eof | ( | void | ) |
This function checks the end of file.
References fat_check_mount_select_open(), fs_g_nav_entry, Fs_management_entry::u32_pos_in_file, and Fs_management_entry::u32_size.
Referenced by file_read(), file_read_buf(), nav_file_paste_state(), and read().
void file_flush | ( | void | ) |
This function flushes the internal cache (file data and file information)
References file_close(), fs_g_nav_entry, and Fs_management_entry::u8_open_mode.
uint16_t file_getc | ( | void | ) |
This function returns the next byte of file.
References fat_read_file(), FOPEN_READ_ACCESS, FS_512B_MASK, FS_CLUST_ACT_ONE, FS_EOF, FS_ERR_EOF, FS_ERR_OUT_LIST, FS_ERR_WRITE_ONLY, fs_g_nav_entry, fs_g_status, Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, and Fs_management_entry::u8_open_mode.
uint32_t file_getpos | ( | void | ) |
This function returns the position in the file.
References fat_check_mount_select_open(), fs_g_nav_entry, and Fs_management_entry::u32_pos_in_file.
bool file_ispresent | ( | void | ) |
This function checks if a file is selected.
References fat_check_is_file(), and fat_check_mount_select().
|
static |
This function stores the global segment variable in other variable.
segment | Pointer on the variable to fill |
References fs_g_nav, fs_g_seg, Fs_segment::u32_addr, Fs_segment::u32_size_or_pos, and Fs_management::u8_lun.
Referenced by file_read().
bool file_open | ( | uint8_t | fopen_mode | ) |
This function opens the selected file.
fopen_mode | option to open the file : FOPEN_MODE_R R access, flux pointer = 0, size not modify FOPEN_MODE_R_PLUS R/W access, flux pointer = 0, size not modify FOPEN_MODE_W W access, flux pointer = 0, size = 0 FOPEN_MODE_W_PLUS R/W access, flux pointer = 0, size = 0 FOPEN_MODE_APPEND W access, flux pointer = at the end, size not modify |
References fat_check_is_file(), fat_check_mount_select_noopen(), fat_check_nav_access_file(), FOPEN_CLEAR_PTR, FOPEN_CLEAR_SIZE, FOPEN_WRITE_ACCESS, FS_ATTR_READ_ONLY, FS_ERR_MODE_NOAVIALABLE, FS_ERR_READ_ONLY, fs_g_nav, fs_g_nav_entry, fs_g_status, FS_LUN_WP, mem_wr_protect(), Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, Fs_management_entry::u8_attr, Fs_management::u8_lun, and Fs_management_entry::u8_open_mode.
Referenced by nav_file_paste_start(), and open().
bool file_putc | ( | uint8_t | u8_byte | ) |
This function writes a byte in the file.
u8_byte | byte to write |
References fat_cache_mark_sector_as_dirty(), fat_check_mount_select_open(), fat_write_file(), FOPEN_WRITE_ACCESS, FS_512B_MASK, FS_CLUST_ACT_ONE, FS_ERR_READ_ONLY, fs_g_nav_entry, fs_g_status, Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, and Fs_management_entry::u8_open_mode.
bool file_read | ( | Fs_file_segment _MEM_TYPE_SLOW_ * | segment | ) |
This function returns a segment (position & size) in a physical memory corresponding at the file.
@param segment Pointer on the segment structure: <br> ->u32_size_or_pos IN, shall contains maximum number of sector to read in file (0 = unlimited) <br> ->u32_size_or_pos OUT, contain the segment size (unit sector) <br> ->other IN, ignored <br> ->other OUT, contains the segment position <br> @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! This routine is interesting to read a file via a DMA and avoid the file system decode //! because this routine returns a physical memory segment without File System information. //! Note: the file can be fragmented and you must call file_read() for each fragments. //!
References fat_check_mount_select_open(), fat_read_file(), file_eof(), file_load_segment_value(), FOPEN_READ_ACCESS, FS_512B, FS_512B_MASK, FS_512B_SHIFT_BIT, FS_CLUST_ACT_SEG, FS_ERR_EOF, FS_ERR_OUT_LIST, FS_ERR_WRITE_ONLY, fs_g_nav, fs_g_nav_entry, fs_g_seg, fs_g_status, LSB1, Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, Fs_segment::u32_size_or_pos, Fs_management::u8_BPB_SecPerClus, and Fs_management_entry::u8_open_mode.
Referenced by nav_file_paste_state().
uint16_t file_read_buf | ( | uint8_t _MEM_TYPE_SLOW_ * | buffer, |
uint16_t | u16_buf_size | ||
) |
This function copies in a buffer the file data corresponding at the current position.
buffer | buffer to fill |
u16_buf_size | buffer size |
References _MEM_TYPE_FAST_, CTRL_GOOD, fat_check_mount_select_open(), fat_read_file(), file_eof(), FOPEN_READ_ACCESS, FS_512B, FS_CLUST_ACT_ONE, FS_CLUST_ACT_SEG, FS_ERR_EOF, FS_ERR_HW, FS_ERR_OUT_LIST, FS_ERR_WRITE_ONLY, fs_g_nav, fs_g_nav_entry, fs_g_seg, fs_g_status, memcpy_ram2ram, memory_2_ram(), Test_align, Fs_segment::u32_addr, Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, Fs_segment::u32_size_or_pos, Fs_management::u8_lun, and Fs_management_entry::u8_open_mode.
Referenced by read().
bool file_seek | ( | uint32_t | u32_pos, |
uint8_t | u8_whence | ||
) |
This function changes the position in the file.
u32_pos | number of byte to seek |
u8_whence | direction of seek FS_SEEK_SET , start at the beginning and forward FS_SEEK_END , start at the end of file and rewind FS_SEEK_CUR_RE, start at the current position and rewind FS_SEEK_CUR_FW, start at the current position and forward |
References fat_check_mount_select_open(), FS_ERR_BAD_POS, fs_g_nav_entry, fs_g_status, FS_SEEK_CUR_FW, FS_SEEK_CUR_RE, FS_SEEK_END, FS_SEEK_SET, Fs_management_entry::u32_pos_in_file, and Fs_management_entry::u32_size.
Referenced by nav_file_paste_state().
bool file_set_eof | ( | void | ) |
This function sets the end of file at the current position.
@return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! This routine is usually used after the last file_write() call. //! The file_write() routine uses the sector unit (512B), //! and you can set a specific byte size with a file_seek() call and fiel_set_eof() call. //!
References fat_cache_flush(), fat_check_mount_select_open(), fat_read_file(), FOPEN_WRITE_ACCESS, FS_CLUST_ACT_CLR, FS_ERR_READ_ONLY, fs_g_nav_entry, fs_g_status, Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, and Fs_management_entry::u8_open_mode.
Referenced by nav_file_paste_state().
bool file_write | ( | Fs_file_segment _MEM_TYPE_SLOW_ * | segment | ) |
This function allocs and returns a segment (position & size) in a physical memory corresponding at the file.
@param segment Pointer on the segment structure: <br> ->u32_size_or_pos IN, shall contains the maximum number of sector to write in file <br> ->u32_size_or_pos OUT, contains the segment size (unit sector) <br> ->other IN, ignored <br> ->other OUT, contains the segment position <br> @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! This routine is interesting to write a file via a DMA and avoid the file system decode //! because this routine returns a physical memory segment without File System information. //! Note: the file can be fragmented and you must call file_write() for each fragments. //!
Referenced by nav_file_paste_state().
uint16_t file_write_buf | ( | uint8_t _MEM_TYPE_SLOW_ * | buffer, |
uint16_t | u16_buf_size | ||
) |
This function transfer a buffer to a file at the current file position.
buffer | data buffer |
u16_buf_size | data size |
References _MEM_TYPE_FAST_, CTRL_GOOD, fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), fat_check_mount_select_open(), fat_write_file(), FOPEN_WRITE_ACCESS, FS_512B, FS_CLUST_ACT_ONE, FS_CLUST_ACT_SEG, FS_ERR_HW, FS_ERR_READ_ONLY, fs_g_nav, fs_g_nav_entry, fs_g_seg, fs_g_status, fs_gu32_addrsector, memcpy_ram2ram, ram_2_memory(), Test_align, Fs_segment::u32_addr, Fs_management_entry::u32_pos_in_file, Fs_management_entry::u32_size, Fs_segment::u32_size_or_pos, Fs_management::u8_lun, and Fs_management_entry::u8_open_mode.
Referenced by write().