PropWare  3.0.0.224
C++ objects and CMake build system for Parallax Propeller
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
PropWare::FatFS Class Reference

#include <PropWare/filesystem/fat/fatfs.h>

+ Inheritance diagram for PropWare::FatFS:
+ Collaboration diagram for PropWare::FatFS:

Public Types

enum  ErrorCode {
  NO_ERROR = 0,
  BEG_ERROR = Filesystem::END_ERROR + 1,
  EMPTY_FAT_ENTRY = BEG_ERROR,
  INVALID_FAT_APPEND,
  TOO_MANY_FATS,
  BAD_SECTORS_PER_CLUSTER,
  READING_PAST_EOC,
  PARTITION_DOES_NOT_EXIST,
  UNSUPPORTED_FILESYSTEM,
  END_ERROR = UNSUPPORTED_FILESYSTEM
}
 

Public Member Functions

 FatFS (const BlockStorage &driver, uint8_t fatBuffer[]=HALF_K_DATA_BUFFER1, const Printer &logger=pwOut)
 Constructor. More...
 
 ~FatFS ()
 Destructor. Unmounts the filesystem and flushes all buffers.
 
PropWare::ErrorCode mount (uint8_t buffer[]=HALF_K_DATA_BUFFER2, const uint8_t partition=0)
 
PropWare::ErrorCode unmount ()
 
uint8_t get_fs_type ()
 Determine whether the mounted filesystem is FAT16 or FAT32. More...
 

Static Public Member Functions

static void print_error_str (const Printer &printer, const ErrorCode err)
 If an error occurs, this method can be used to determine what that error actually means. More...
 

Static Public Attributes

static const int FOLDER_ID = INT32_MAX
 

Friends

class FatFile
 
class FatFileReader
 
class FatFileWriter
 

Detailed Description

FAT 16/32 filesystem driver - can be used with SD cards or any other PropWare::BlockStorage device

Examples
FileReader_Demo.cpp, and FileWriter_Demo.cpp.

Definition at line 43 of file fatfs.h.

Member Enumeration Documentation

◆ ErrorCode

Enumerator
EMPTY_FAT_ENTRY 

FatFS Error 0

INVALID_FAT_APPEND 

FatFS Error 1

TOO_MANY_FATS 

FatFS Error 2

BAD_SECTORS_PER_CLUSTER 

FatFS Error 3

READING_PAST_EOC 

FatFS Error 4

PARTITION_DOES_NOT_EXIST 

FatFS Error 5

UNSUPPORTED_FILESYSTEM 

FatFS Error 6

END_ERROR 

Last FatFS error

Definition at line 51 of file fatfs.h.

Constructor & Destructor Documentation

◆ FatFS()

PropWare::FatFS::FatFS ( const BlockStorage driver,
uint8_t  fatBuffer[] = HALF_K_DATA_BUFFER1,
const Printer logger = pwOut 
)

Constructor.

Parameters
[in]*driverAddress of a the driver which is capable of reading the physical hardware. Commonly, this would be an instance of PropWare::SD, but one could potentially write a driver for a floppy disk or CD driver or any other block storage device
[in]fatBuffer[]Byte array that can be used to store blocks of the file allocation table (FAT) used during mounting, file searching, and file expansion.
[in]*loggerUseful for debugging, a logger can be given to help determine when something goes wrong. All code using the logger will be optimized out by GCC so long as you only call public method
Warning
The default value for the buffer[] parameter is only valid when using a SD card or other PropWare::BlockStorage driver with a block size of 512-bytes or less.

Definition at line 81 of file fatfs.h.

Member Function Documentation

◆ get_fs_type()

uint8_t PropWare::FatFS::get_fs_type ( )

Determine whether the mounted filesystem is FAT16 or FAT32.

Returns
2 (also known as PropWare::FatFS::FAT16) for FAT16, 4 (also known as PropWare::FatFS::FAT32) for FAT32

Definition at line 149 of file fatfs.h.

◆ mount()

PropWare::ErrorCode PropWare::FatFS::mount ( uint8_t  buffer[] = HALF_K_DATA_BUFFER2,
const uint8_t  partition = 0 
)
virtual
See also
PropWare::Filesystem::mount
Warning
The default value for the buffer[] parameter is only valid when using a SD card or other PropWare::BlockStorage driver with a block size of 512-bytes or less.

Implements PropWare::Filesystem.

Definition at line 103 of file fatfs.h.

◆ print_error_str()

static void PropWare::Filesystem::print_error_str ( const Printer printer,
const ErrorCode  err 
)
staticinherited

If an error occurs, this method can be used to determine what that error actually means.

Parameters
[in]printerWhere the error should be printed
[in]errThe error code that was thrown

Definition at line 78 of file filesystem.h.

+ Here is the call graph for this function:

◆ unmount()

PropWare::ErrorCode PropWare::FatFS::unmount ( )
virtual
See also
PropWare::Filesystem::unmount

Implements PropWare::Filesystem.

Definition at line 136 of file fatfs.h.

+ Here is the caller graph for this function:

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