FatReader implements a minimal FAT16/FAT32 file reader class.
More...
#include <FatReader.h>
FatReader implements a minimal FAT16/FAT32 file reader class.
◆ FatReader()
FatReader::FatReader |
( |
void |
| ) |
|
|
inline |
◆ ls()
void FatReader::ls |
( |
uint8_t |
flags = 0 | ) |
|
list file in a directory
- Parameters
-
◆ openRoot()
uint8_t FatReader::openRoot |
( |
FatVolume & |
vol | ) |
|
Open a volume's root directory.
- Parameters
-
[in] | vol | The FAT volume containing the root directory to be opened. |
- Returns
- The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include the FAT volume has not been initialized or it a FAT12 volume.
◆ open() [1/3]
Open a file or subdirectory by directory structure.
- Parameters
-
[in] | vol | The FAT volume that contains the file or subdirectory. |
[in] | dir | The directory structure describing the file or subdirectory. |
- Returns
- The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include the FAT volume, vol, has not been initialized, vol is a FAT12 volume or dir is not a valid directory entry.
◆ open() [2/3]
uint8_t FatReader::open |
( |
FatReader & |
dir, |
|
|
char * |
name |
|
) |
| |
Open a file or subdirectory by name.
- Note
- The file or subdirectory, name, must be in the specified directory, dir, and must have a DOS 8.3 name.
- Parameters
-
[in] | dir | An open FatReader instance for the directory. |
[in] | name | A valid 8.3 DOS name for a file or subdirectory in the directory dir. |
- Returns
- The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include the FAT volume has not been initialized, dir is not a directory, name is invalid, the file or subdirectory does not exist, or an I/O error occurred.
◆ open() [3/3]
uint8_t FatReader::open |
( |
FatReader & |
dir, |
|
|
uint16_t |
index |
|
) |
| |
Open a file or subdirectory by index.
- Parameters
-
[in] | dir | An open FatReader instance for the directory. |
[in] | index | The index for a file or subdirectory in the directory dir. index is the byte offset divided by 32 of the directory entry for the file or subdirectory. |
To determine the index for a file open it by name. The index for the file is then is: (dir.readPosition()/32 -1)
- Returns
- The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include the FAT volume has not been initialized, dir is not a directory, name is invalid, the file or subdirectory does not exist, or an I/O error occurred.
◆ optimizeContiguous()
void FatReader::optimizeContiguous |
( |
void |
| ) |
|
Check for a contiguous file and enable optimized reads if the file is contiguous.
◆ read()
int16_t FatReader::read |
( |
void * |
buf, |
|
|
uint16_t |
count |
|
) |
| |
Read data from a file at starting at the current read position.
- Parameters
-
[out] | buf | Pointer to the location that will receive the data. |
[in] | count | Maximum number of bytes to read. |
- Returns
- For success read() returns the number of bytes read. A value less than count, including zero, will be returned if end of file is reached. If an error occurs, read() returns -1. Possible errors include read() called before a file has been opened, corrupt file system or an I/O error occurred.
◆ readDir()
int8_t FatReader::readDir |
( |
dir_t & |
dir | ) |
|
Read the next directory entry from a directory file.
- Parameters
-
[out] | dir | The dir_t struct that will receive the data. |
- Returns
- For success readDir() returns the number of bytes read. A value of zero will be returned if end of file is reached. If an error occurs, readDir() returns -1. Possible errors include readDir() called before a directory has been opened, this is not a directory file or an I/O error occurred.
◆ rewind()
void FatReader::rewind |
( |
void |
| ) |
|
Set read position to start of file
◆ seekCur()
uint8_t FatReader::seekCur |
( |
uint32_t |
offset | ) |
|
Set the read position for a file or directory to the current position plus offset.
- Parameters
-
[in] | offset | The amount to advance the read position. |
- Returns
- The value one, true, is returned for success and the value zero, false, is returned for failure.
◆ close()
void FatReader::close |
( |
void |
| ) |
|
|
inline |
◆ fileSize()
uint32_t FatReader::fileSize |
( |
void |
| ) |
|
|
inline |
- Returns
- The total number of bytes in a file or directory.
◆ fileType()
uint8_t FatReader::fileType |
( |
void |
| ) |
|
|
inline |
Type of this FatReader. You should use isFile() or isDir() instead of type() if possible.
- Returns
- The file or directory type.
◆ firstCluster()
uint32_t FatReader::firstCluster |
( |
void |
| ) |
|
|
inline |
- Returns
- The first cluster number for a file or directory.
◆ isContiguous()
uint8_t FatReader::isContiguous |
( |
void |
| ) |
|
|
inline |
◆ isDir()
uint8_t FatReader::isDir |
( |
void |
| ) |
|
|
inline |
- Returns
- True if this is a FatReader for a directory else false
◆ isFile()
uint8_t FatReader::isFile |
( |
void |
| ) |
|
|
inline |
- Returns
- True if this is a FatReader for a file else false
◆ isOpen()
uint8_t FatReader::isOpen |
( |
void |
| ) |
|
|
inline |
- Returns
- True if FatReader is for an open file/directory else false
◆ readCluster()
uint32_t FatReader::readCluster |
( |
void |
| ) |
|
|
inline |
- Returns
- The current cluster number for a file or directory.
◆ readPosition()
uint32_t FatReader::readPosition |
( |
void |
| ) |
|
|
inline |
- Returns
- The read position for a file or directory.
◆ seekSet()
uint8_t FatReader::seekSet |
( |
uint32_t |
pos | ) |
|
|
inline |
Set the read position for a file or directory to pos.
- Parameters
-
[in] | pos | The new read position in bytes from the beginning of the file. |
- Returns
- The value one, true, is returned for success and the value zero, false, is returned for failure.
◆ volume()
get the parent volume
- Returns
- the parent volume
The documentation for this class was generated from the following files: