Soldered SD Card Arduino Library 1.0.0
Easily read and write files to and form the SD card breakout! A fork of the original SDFat library by Bill Greiman.
Loading...
Searching...
No Matches
FatPartition Class Reference

Access FAT16 and FAT32 partitions on raw file devices. More...

#include <FatPartition.h>

Inherited by FatVolume.

Public Member Functions

 FatPartition ()
 
uint8_t bytesPerClusterShift () const
 
uint16_t bytesPerCluster () const
 
uint16_t bytesPerSector () const
 
uint8_t bytesPerSectorShift () const
 
uint16_t sectorMask () const
 
uint8_t sectorsPerCluster () const
 
uint8_t blocksPerCluster () __attribute__((deprecated))
 
uint32_t sectorsPerFat () const
 
uint8_t * cacheClear ()
 
uint32_t clusterCount () const
 
uint8_t sectorsPerClusterShift () const
 
uint32_t dataStartSector () const
 
uint8_t fatCount () const
 
uint32_t fatStartSector () const
 
uint8_t fatType () const
 
int32_t freeClusterCount ()
 
bool init (BlockDevice *dev, uint8_t part=1)
 
uint16_t rootDirEntryCount () const
 
uint32_t rootDirStart () const
 
uint32_t volumeSectorCount () const
 
int8_t dbgFat (uint32_t n, uint32_t *v)
 
bool isBusy ()
 
void dmpDirSector (print_t *pr, uint32_t sector)
 
void dmpFat (print_t *pr, uint32_t start, uint32_t count)
 
void dmpRootDir (print_t *pr)
 
void dmpSector (print_t *pr, uint32_t sector, uint8_t bits=8)
 

Private Member Functions

bool cacheSafeRead (uint32_t sector, uint8_t *dst)
 
bool cacheSafeRead (uint32_t sector, uint8_t *dst, size_t count)
 
bool cacheSafeWrite (uint32_t sector, const uint8_t *dst)
 
bool cacheSafeWrite (uint32_t sector, const uint8_t *dst, size_t count)
 
bool readSector (uint32_t sector, uint8_t *dst)
 
bool syncDevice ()
 
bool writeSector (uint32_t sector, const uint8_t *src)
 
void setFreeClusterCount (int32_t value)
 
void updateFreeClusterCount (int32_t change)
 
void setFreeClusterCount (int32_t value)
 
void updateFreeClusterCount (int32_t change)
 
cache_tcacheFetchFat (uint32_t sector, uint8_t options)
 
bool cacheSync ()
 
cache_tcacheFetchFat (uint32_t sector, uint8_t options)
 
bool cacheSync ()
 
cache_tcacheFetchData (uint32_t sector, uint8_t options)
 
void cacheInvalidate ()
 
bool cacheSyncData ()
 
cache_tcacheAddress ()
 
uint32_t cacheSectorNumber ()
 
void cacheDirty ()
 
bool allocateCluster (uint32_t current, uint32_t *next)
 
bool allocContiguous (uint32_t count, uint32_t *firstCluster)
 
uint8_t sectorOfCluster (uint32_t position) const
 
uint32_t clusterStartSector (uint32_t cluster) const
 
int8_t fatGet (uint32_t cluster, uint32_t *value)
 
bool fatPut (uint32_t cluster, uint32_t value)
 
bool fatPutEOC (uint32_t cluster)
 
bool freeChain (uint32_t cluster)
 
bool isEOC (uint32_t cluster) const
 

Private Attributes

BlockDevicem_blockDev
 
uint8_t m_sectorsPerCluster
 
uint8_t m_clusterSectorMask
 
uint8_t m_sectorsPerClusterShift
 
uint8_t m_fatType = 0
 
uint16_t m_rootDirEntryCount
 
uint32_t m_allocSearchStart
 
uint32_t m_sectorsPerFat
 
uint32_t m_dataStartSector
 
uint32_t m_fatStartSector
 
uint32_t m_lastCluster
 
uint32_t m_rootDirStart
 
int32_t m_freeClusterCount
 
FsCache m_cache
 
FsCache m_fatCache
 

Static Private Attributes

static const uint8_t m_bytesPerSectorShift = 9
 
static const uint16_t m_bytesPerSector = 512
 
static const uint16_t m_sectorMask = 0x1FF
 

Friends

class FatFile
 

Detailed Description

Access FAT16 and FAT32 partitions on raw file devices.

Constructor & Destructor Documentation

◆ FatPartition()

FatPartition::FatPartition ( )
inline

Create an instance of FatPartition

Member Function Documentation

◆ allocateCluster()

bool FatPartition::allocateCluster ( uint32_t  current,
uint32_t *  next 
)
private

◆ allocContiguous()

bool FatPartition::allocContiguous ( uint32_t  count,
uint32_t *  firstCluster 
)
private

◆ blocksPerCluster()

uint8_t FatPartition::blocksPerCluster ( )
inline

◆ bytesPerCluster()

uint16_t FatPartition::bytesPerCluster ( ) const
inline
Returns
Number of bytes in a cluster.

◆ bytesPerClusterShift()

uint8_t FatPartition::bytesPerClusterShift ( ) const
inline
Returns
The shift count required to multiply by bytesPerCluster.

◆ bytesPerSector()

uint16_t FatPartition::bytesPerSector ( ) const
inline
Returns
Number of bytes per sector.

◆ bytesPerSectorShift()

uint8_t FatPartition::bytesPerSectorShift ( ) const
inline
Returns
The shift count required to multiply by bytesPerCluster.

◆ cacheAddress()

cache_t * FatPartition::cacheAddress ( )
inlineprivate

◆ cacheClear()

uint8_t * FatPartition::cacheClear ( )
inline

Clear the cache and returns a pointer to the cache. Not for normal apps.

Returns
A pointer to the cache buffer or zero if an error occurs.

◆ cacheDirty()

void FatPartition::cacheDirty ( )
inlineprivate

◆ cacheFetchData()

cache_t * FatPartition::cacheFetchData ( uint32_t  sector,
uint8_t  options 
)
inlineprivate

◆ cacheFetchFat() [1/2]

cache_t * FatPartition::cacheFetchFat ( uint32_t  sector,
uint8_t  options 
)
inlineprivate

◆ cacheFetchFat() [2/2]

cache_t * FatPartition::cacheFetchFat ( uint32_t  sector,
uint8_t  options 
)
inlineprivate

◆ cacheInvalidate()

void FatPartition::cacheInvalidate ( )
inlineprivate

◆ cacheSafeRead() [1/2]

bool FatPartition::cacheSafeRead ( uint32_t  sector,
uint8_t *  dst 
)
inlineprivate

◆ cacheSafeRead() [2/2]

bool FatPartition::cacheSafeRead ( uint32_t  sector,
uint8_t *  dst,
size_t  count 
)
inlineprivate

◆ cacheSafeWrite() [1/2]

bool FatPartition::cacheSafeWrite ( uint32_t  sector,
const uint8_t *  dst 
)
inlineprivate

◆ cacheSafeWrite() [2/2]

bool FatPartition::cacheSafeWrite ( uint32_t  sector,
const uint8_t *  dst,
size_t  count 
)
inlineprivate

◆ cacheSectorNumber()

uint32_t FatPartition::cacheSectorNumber ( )
inlineprivate

◆ cacheSync() [1/2]

bool FatPartition::cacheSync ( )
inlineprivate

◆ cacheSync() [2/2]

bool FatPartition::cacheSync ( )
inlineprivate

◆ cacheSyncData()

bool FatPartition::cacheSyncData ( )
inlineprivate

◆ clusterCount()

uint32_t FatPartition::clusterCount ( ) const
inline
Returns
The total number of clusters in the volume.

◆ clusterStartSector()

uint32_t FatPartition::clusterStartSector ( uint32_t  cluster) const
inlineprivate

◆ dataStartSector()

uint32_t FatPartition::dataStartSector ( ) const
inline
Returns
The logical sector number for the start of file data.

◆ dbgFat()

int8_t FatPartition::dbgFat ( uint32_t  n,
uint32_t *  v 
)
inline

Debug access to FAT table

Parameters
[in]ncluster number.
[out]vvalue of entry
Returns
-1 error, 0 EOC, else 1.

◆ dmpDirSector()

void FatPartition::dmpDirSector ( print_t pr,
uint32_t  sector 
)

◆ dmpFat()

void FatPartition::dmpFat ( print_t pr,
uint32_t  start,
uint32_t  count 
)

◆ dmpRootDir()

void FatPartition::dmpRootDir ( print_t pr)

◆ dmpSector()

void FatPartition::dmpSector ( print_t pr,
uint32_t  sector,
uint8_t  bits = 8 
)

◆ fatCount()

uint8_t FatPartition::fatCount ( ) const
inline
Returns
The number of File Allocation Tables.

◆ fatGet()

int8_t FatPartition::fatGet ( uint32_t  cluster,
uint32_t *  value 
)
private

◆ fatPut()

bool FatPartition::fatPut ( uint32_t  cluster,
uint32_t  value 
)
private

◆ fatPutEOC()

bool FatPartition::fatPutEOC ( uint32_t  cluster)
inlineprivate

◆ fatStartSector()

uint32_t FatPartition::fatStartSector ( ) const
inline
Returns
The logical sector number for the start of the first FAT.

◆ fatType()

uint8_t FatPartition::fatType ( ) const
inline
Returns
The FAT type of the volume. Values are 12, 16 or 32.

◆ freeChain()

bool FatPartition::freeChain ( uint32_t  cluster)
private

◆ freeClusterCount()

int32_t FatPartition::freeClusterCount ( )

Volume free space in clusters.

Returns
Count of free clusters for success or -1 if an error occurs.

◆ init()

bool FatPartition::init ( BlockDevice dev,
uint8_t  part = 1 
)

Initialize a FAT partition.

Parameters
[in]devBlockDevice for this partition.
[in]partThe partition to be used. Legal values for part are 1-4 to use the corresponding partition on a device formatted with a MBR, Master Boot Record, or zero if the device is formatted as a super floppy with the FAT boot sector in sector zero.
Returns
true for success or false for failure.

◆ isBusy()

bool FatPartition::isBusy ( )
inline

Check for BlockDevice busy.

Returns
true if busy else false.

◆ isEOC()

bool FatPartition::isEOC ( uint32_t  cluster) const
inlineprivate

◆ readSector()

bool FatPartition::readSector ( uint32_t  sector,
uint8_t *  dst 
)
inlineprivate

◆ rootDirEntryCount()

uint16_t FatPartition::rootDirEntryCount ( ) const
inline
Returns
The number of entries in the root directory for FAT16 volumes.

◆ rootDirStart()

uint32_t FatPartition::rootDirStart ( ) const
inline
Returns
The logical sector number for the start of the root directory on FAT16 volumes or the first cluster number on FAT32 volumes.

◆ sectorMask()

uint16_t FatPartition::sectorMask ( ) const
inline
Returns
Mask for sector offset.

◆ sectorOfCluster()

uint8_t FatPartition::sectorOfCluster ( uint32_t  position) const
inlineprivate

◆ sectorsPerCluster()

uint8_t FatPartition::sectorsPerCluster ( ) const
inline
Returns
The volume's cluster size in sectors.

◆ sectorsPerClusterShift()

uint8_t FatPartition::sectorsPerClusterShift ( ) const
inline
Returns
The shift count required to multiply by sectorsPerCluster.

◆ sectorsPerFat()

uint32_t FatPartition::sectorsPerFat ( ) const
inline
Returns
The number of sectors in one FAT.

◆ setFreeClusterCount() [1/2]

void FatPartition::setFreeClusterCount ( int32_t  value)
inlineprivate

◆ setFreeClusterCount() [2/2]

void FatPartition::setFreeClusterCount ( int32_t  value)
inlineprivate

◆ syncDevice()

bool FatPartition::syncDevice ( )
inlineprivate

◆ updateFreeClusterCount() [1/2]

void FatPartition::updateFreeClusterCount ( int32_t  change)
inlineprivate

◆ updateFreeClusterCount() [2/2]

void FatPartition::updateFreeClusterCount ( int32_t  change)
inlineprivate

◆ volumeSectorCount()

uint32_t FatPartition::volumeSectorCount ( ) const
inline
Returns
The number of sectors in the volume

◆ writeSector()

bool FatPartition::writeSector ( uint32_t  sector,
const uint8_t *  src 
)
inlineprivate

Friends And Related Symbol Documentation

◆ FatFile

friend class FatFile
friend

FatFile allowed access to private members.

Member Data Documentation

◆ m_allocSearchStart

uint32_t FatPartition::m_allocSearchStart
private

◆ m_blockDev

BlockDevice* FatPartition::m_blockDev
private

◆ m_bytesPerSector

const uint16_t FatPartition::m_bytesPerSector = 512
staticprivate

◆ m_bytesPerSectorShift

const uint8_t FatPartition::m_bytesPerSectorShift = 9
staticprivate

◆ m_cache

FsCache FatPartition::m_cache
private

◆ m_clusterSectorMask

uint8_t FatPartition::m_clusterSectorMask
private

◆ m_dataStartSector

uint32_t FatPartition::m_dataStartSector
private

◆ m_fatCache

FsCache FatPartition::m_fatCache
private

◆ m_fatStartSector

uint32_t FatPartition::m_fatStartSector
private

◆ m_fatType

uint8_t FatPartition::m_fatType = 0
private

◆ m_freeClusterCount

int32_t FatPartition::m_freeClusterCount
private

◆ m_lastCluster

uint32_t FatPartition::m_lastCluster
private

◆ m_rootDirEntryCount

uint16_t FatPartition::m_rootDirEntryCount
private

◆ m_rootDirStart

uint32_t FatPartition::m_rootDirStart
private

◆ m_sectorMask

const uint16_t FatPartition::m_sectorMask = 0x1FF
staticprivate

◆ m_sectorsPerCluster

uint8_t FatPartition::m_sectorsPerCluster
private

◆ m_sectorsPerClusterShift

uint8_t FatPartition::m_sectorsPerClusterShift
private

◆ m_sectorsPerFat

uint32_t FatPartition::m_sectorsPerFat
private

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