WaveHC
Public Member Functions
FatReader Class Reference

FatReader implements a minimal FAT16/FAT32 file reader class. More...

#include <FatReader.h>

Collaboration diagram for FatReader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FatReader (void)
void ls (uint8_t flags=0)
uint8_t openRoot (FatVolume &vol)
uint8_t open (FatVolume &vol, dir_t &dir)
uint8_t open (FatReader &dir, char *name)
uint8_t open (FatReader &dir, uint16_t index)
void optimizeContiguous (void)
int16_t read (void *buf, uint16_t count)
int8_t readDir (dir_t &dir)
void rewind (void)
uint8_t seekCur (uint32_t pos)
void close (void)
uint32_t fileSize (void)
uint8_t fileType (void)
uint32_t firstCluster (void)
uint8_t isContiguous (void)
uint8_t isDir (void)
uint8_t isFile (void)
uint8_t isOpen (void)
uint32_t readCluster (void)
uint32_t readPosition (void)
uint8_t seekSet (uint32_t pos)
FatVolumevolume (void)

Detailed Description

FatReader implements a minimal FAT16/FAT32 file reader class.


Constructor & Destructor Documentation

FatReader::FatReader ( void  ) [inline]

Create an instance of FatReader.


Member Function Documentation

void FatReader::close ( void  ) [inline]

Close this instance of FatReader.

uint32_t FatReader::fileSize ( void  ) [inline]
Returns:
The total number of bytes in a file or directory.
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.
uint32_t FatReader::firstCluster ( void  ) [inline]
Returns:
The first cluster number for a file or directory.
uint8_t FatReader::isContiguous ( void  ) [inline]
Returns:
True if the bit for optimized reads is set. See optimizeContiguous().
uint8_t FatReader::isDir ( void  ) [inline]
Returns:
True if this is a FatReader for a directory else false
uint8_t FatReader::isFile ( void  ) [inline]
Returns:
True if this is a FatReader for a file else false
uint8_t FatReader::isOpen ( void  ) [inline]
Returns:
True if FatReader is for an open file/directory else false
void FatReader::ls ( uint8_t  flags = 0)

List file in a directory

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]dirAn open FatReader instance for the directory.
[in]nameA 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.
uint8_t FatReader::open ( FatReader dir,
uint16_t  index 
)

Open a file or subdirectory by index.

Parameters:
[in]dirAn open FatReader instance for the directory.
[in]indexThe 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.
uint8_t FatReader::open ( FatVolume vol,
dir_t dir 
)

Open a file or subdirectory by directory structure.

Parameters:
[in]volThe FAT volume that contains the file or subdirectory.
[in]dirThe 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.
uint8_t FatReader::openRoot ( FatVolume vol)

Open a volume's root directory.

Parameters:
[in]volThe 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.
void FatReader::optimizeContiguous ( void  )

Check for a contiguous file and enable optimized reads if the file is contiguous.

int16_t FatReader::read ( void *  buf,
uint16_t  count 
)

Read data from a file at starting at the current read position.

Parameters:
[out]bufPointer to the location that will receive the data.
[in]countMaximum 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.
uint32_t FatReader::readCluster ( void  ) [inline]
Returns:
The current cluster number for a file or directory.
int8_t FatReader::readDir ( dir_t dir)

Read the next directory entry from a directory file.

Parameters:
[out]dirThe 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.
uint32_t FatReader::readPosition ( void  ) [inline]
Returns:
The read position for a file or directory.
void FatReader::rewind ( void  )

Set read position to start of file

uint8_t FatReader::seekCur ( uint32_t  offset)

Set the read position for a file or directory to the current position plus offset.

Parameters:
[in]offsetThe amount to advance the read position.
Returns:
The value one, true, is returned for success and the value zero, false, is returned for failure.
uint8_t FatReader::seekSet ( uint32_t  pos) [inline]

Set the read position for a file or directory to pos.

Parameters:
[in]posThe 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.
FatVolume* FatReader::volume ( void  ) [inline]

Parent volume


The documentation for this class was generated from the following files: