95int8_t
find(
const char *name,
File &f, uint8_t *buf);
120int8_t
match(
const File &dir,
const char *pattern, uint8_t skip,
File &f,
char *nameOut, uint8_t *buf);
134typedef bool (*
ListFn)(
const char *name,
const File &f,
bool isDir,
void *ctx);
166int8_t
runs(
const File &f,
Run *out, uint8_t maxRuns, uint8_t *buf);
180uint8_t
open(
const char *name,
Run *out, uint8_t maxRuns, uint8_t *buf);
190bool read(
const Run *run, uint32_t nRuns, uint32_t k, uint8_t *dst);
The FAT16/FAT32 reader (CHSd).
Definition Fat.h:46
int8_t root(File &dir)
The root directory as a folder, for match() and list().
int8_t find(const char *name, File &f, uint8_t *buf)
Finds a file in the root directory.
int8_t list(const File &dir, ListFn fn, void *ctx, uint8_t *buf)
Walks a directory, handing every file and folder in it to fn, in directory order.
uint8_t open(const char *name, Run *out, uint8_t maxRuns, uint8_t *buf)
The usual way in: sd::init(), mount(), find() and runs() in one go.
Err
What the functions that return an int8_t report: OK (0) or a negative error.
Definition Fat.h:50
@ E_NOFS
no FAT16/FAT32 volume: no partition, bad BPB, FAT12
Definition Fat.h:53
@ E_FRAG
more runs than the caller has room for
Definition Fat.h:56
@ OK
success
Definition Fat.h:51
@ E_EXFAT
exFAT (or NTFS) volume: reformat the card as FAT32
Definition Fat.h:54
@ E_CHAIN
cluster chain broken, looped, or not the file's length
Definition Fat.h:57
@ E_NOTFOUND
no such file or directory (or not mounted)
Definition Fat.h:55
@ E_READ
the card did not deliver a block
Definition Fat.h:52
int8_t runs(const File &f, Run *out, uint8_t maxRuns, uint8_t *buf)
Walks a file's cluster chain once and returns its extents: the runs of consecutive card blocks that h...
int8_t match(const File &dir, const char *pattern, uint8_t skip, File &f, char *nameOut, uint8_t *buf)
Finds the (skip + 1)th file in a folder whose name fits a pattern.
bool(* ListFn)(const char *name, const File &f, bool isDir, void *ctx)
What list() calls for each entry of a directory.
Definition Fat.h:134
bool read(const Run *run, uint32_t nRuns, uint32_t k, uint8_t *dst)
Reads block k of a file through its runs.
int8_t mount(uint8_t *buf)
Finds the FAT volume on the card and remembers where its parts are.
int8_t folder(const char *name, File &dir, uint8_t *buf)
Finds a folder in the root directory, for match() and list().
A file or folder found in a directory: where it starts and how long it is.
Definition Fat.h:70
uint32_t size
Its size in bytes (0 for a folder).
Definition Fat.h:70
uint32_t cluster
Its first cluster (0 for an empty file; for root(), the FAT16 root's 0 or the FAT32 root's cluster).
Definition Fat.h:70
A run of consecutive card blocks holding part of a file (see runs()).
Definition Fat.h:62
uint32_t lba
The run's first block on the card (an LBA, as sd::read() takes it).
Definition Fat.h:62
uint32_t blocks
How many 512-byte blocks the run holds (at least 1).
Definition Fat.h:62