Difference: MicroSdBlocks (11 vs. 12)

Revision 122020-06-22 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
%DASHBOARD{ section="banner"
Line: 221 to 221
 

FAT Filesystem

Changed:
<
<
TBC Based on FatFs - Generic FAT Filesystem Module
>
>
Based on FatFs - Generic FAT Filesystem Module. FAT32 and exFAT
  Forth source files
Added:
>
>

FAT Filesystem API

The C function prototype for f_open looks like this:

FRESULT f_open (
  FIL* fp,           /* [OUT] Pointer to the file object structure */
  const TCHAR* path, /* [IN] File name */
  BYTE mode          /* [IN] Mode flags */
);

The parameter order for the Forth Word is the same: a1 is address of the file object structure, a2 is the address of the filename array (0 terminated string).

f_open  ( a1 a2 w -- u )   opens a file.

typedef struct {
    FFOBJID obj;          /* Object identifier */
    BYTE    flag;         /* File object status flags */
    BYTE    err;          /* Abort flag (error code) */
    FSIZE_t fptr;         /* File read/write pointer (Byte offset origin from top of the file) */
    DWORD   clust;        /* Current cluster of fptr (One cluster behind if fptr is on the cluster boundary. Invalid if fptr == 0.) */
    LBA_t   sect;         /* Current data sector (Can be invalid if fptr is on the cluster boundary.)*/
#if !FF_FS_READONLY
    LBA_t   dir_sect;     /* Sector number containing the directory entry */
    BYTE*   dir_ptr;      /* Ponter to the directory entry in the window */
#endif
#if FF_USE_FASTSEEK
    DWORD*  cltbl;        /* Pointer to the cluster link map table (Nulled on file open. Set by application.) */
#endif
#if !FF_FS_TINY
    BYTE    buf[FF_MAX_SS]; /* File private data transfer buffer (Always valid if fptr is not on the sector boundary but can be invalid if fptr is on the sector boundary.) */
#endif
} FIL;

FIL name ( -- a ) creates a file object

See also f_open

File Access

  • f_open - Open/Create a file
  • f_close - Close an open file
  • f_read - Read data from the file
  • f_write - Write data to the file
  • f_lseek - Move read/write pointer, Expand size
  • f_truncate - Truncate file size
  • f_sync - Flush cached data
  • f_forward - Forward data to the stream
  • f_expand - Allocate a contiguous block to the file
  • f_gets - Read a string
  • f_putc - Write a character
  • f_puts - Write a string
  • f_printf - Write a formatted string
  • f_tell - Get current read/write pointer
  • f_eof - Test for end-of-file
  • f_size - Get size
  • f_error - Test for an error

Directory Access

  • f_opendir - Open a directory
  • f_closedir - Close an open directory
  • f_readdir - Read a directory item
  • f_findfirst - Open a directory and read the first item matched
  • f_findnext - Read a next item matched

File and Directory Management

  • f_stat - Check existance of a file or sub-directory
  • f_unlink - Remove a file or sub-directory
  • f_rename - Rename/Move a file or sub-directory
  • f_chmod - Change attribute of a file or sub-directory
  • f_utime - Change timestamp of a file or sub-directory
  • f_mkdir - Create a sub-directory
  • f_chdir - Change current directory
  • f_chdrive - Change current drive
  • f_getcwd - Retrieve the current directory and drive

Volume Management and System Configuration

  • f_mount - Register/Unregister the work area of the volume
  • f_mkfs - Create an FAT volume on the logical drive
  • f_fdisk - Create partitions on the physical drive
  • f_getfree - Get free space on the volume
  • f_getlabel - Get volume label
  • f_setlabel - Set volume label
  • f_setcp - Set active code page

FAT Filesystem UNIX like Shell Commands

  • ls
  • pwd
  • cd
  • cp
  • mv
  • rm
  • chmod
  • cat
  • less
  • mkdir
  • mount
  • umount
  • mkfs
  • dd
  • df
  • du
  • touch

  • date
  • ps
  • kill
  • vi
 
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback