SdFat: SdFs Class Reference

SdFat

Public Member Functions | List of all members
SdFs Class Reference

SD file system class for FAT16, FAT32, and exFAT volumes. More...

`#include <SdFat.h>`

Inheritance diagram for SdFs:
[legend]
Collaboration diagram for SdFs:
[legend]

## Public Member Functions
bool | begin (BlockDevice *blockDev)
bool | begin (SdCsPin_t csPin, uint32_t maxSck)
bool | begin (SdCsPin_t csPin=SS)
bool | begin (SdioConfig sdioConfig)
bool | begin (SdSpiConfig spiConfig)
uint32_t | bytesPerCluster () const
SdCard * | card ()
bool | cardBegin (SdioConfig sdioConfig)
bool | cardBegin (SdSpiConfig spiConfig)
bool | chdir ()
bool | chdir (const char *path)
void | chvol ()
uint32_t | clusterCount () const
uint32_t | dataStartSector () const
void | end ()
void | errorHalt (print_t *pr)
void | errorHalt (print_t *pr, const __FlashStringHelper *msg)
void | errorHalt (print_t *pr, const char *msg)
void | errorPrint (Print *pr, const __FlashStringHelper *msg)
void | errorPrint (print_t *pr)
void | errorPrint (print_t *pr, char const *msg)
bool | exists (const char *path)
uint32_t | fatStartSector () const
uint8_t | fatType () const
bool | format (print_t *pr=NULL)
uint32_t | freeClusterCount () const
void | initErrorHalt (Print *pr, const __FlashStringHelper *msg)
void | initErrorHalt (print_t *pr)
void | initErrorHalt (print_t *pr, const char *msg)
void | initErrorPrint (Print *pr)
bool | isBusy ()
bool | ls (print_t *pr)
bool | ls (print_t *pr, const char *path, uint8_t flags)
bool | ls (print_t *pr, uint8_t flags)
bool | mkdir (const char *path, bool pFlag=true)
FsFile | open (const char *path, oflag_t oflag=0X00)
void | printFatType (print_t *pr)
void | printSdError (print_t *pr)
bool | remove (const char *path)
bool | rename (const char *oldPath, const char *newPath)
bool | rmdir (const char *path)
uint8_t | sdErrorCode ()
uint8_t | sdErrorData ()
uint32_t | sectorsPerCluster () const
FsVolume * | vol ()
bool | volumeBegin ()

## Detailed Description

SD file system class for FAT16, FAT32, and exFAT volumes.

## Member Function Documentation

## ◆ begin() [1/5]

bool FsVolume::begin | ( | BlockDevice * | blockDev | ) |
| inherited

Initialize an FatVolume object.

Parameters

  [in] | blockDev | Device block driver.

Returns
  true for success or false for failure.

## ◆ begin() [2/5]

bool SdBase< FsVolume >::begin | ( | SdCsPin_t | csPin,
|  | uint32_t | maxSck
| ) |  |
| inlineinherited

Initialize SD card and file system.

Parameters

  [in] | csPin | SD card chip select pin.
  [in] | maxSck | Maximum SCK frequency.

Returns
  true for success or false for failure.

## ◆ begin() [3/5]

bool SdBase< FsVolume >::begin | ( | SdCsPin_t | csPin = `SS` | ) |
| inlineinherited

Initialize SD card and file system.

Parameters

  [in] | csPin | SD card chip select pin.

Returns
  true for success or false for failure.

## ◆ begin() [4/5]

bool SdBase< FsVolume >::begin | ( | SdioConfig | sdioConfig | ) |
| inlineinherited

Initialize SD card and file system for SDIO mode.

Parameters

  [in] | sdioConfig | SDIO configuration.

Returns
  true for success or false for failure.

## ◆ begin() [5/5]

bool SdBase< FsVolume >::begin | ( | SdSpiConfig | spiConfig | ) |
| inlineinherited

Initialize SD card and file system for SPI mode.

Parameters

  [in] | spiConfig | SPI configuration.

Returns
  true for success or false for failure.

## ◆ bytesPerCluster()

uint32_t FsVolume::bytesPerCluster | ( |  | ) | const
| inlineinherited

Returns
  the number of bytes in a cluster.

## ◆ card()

SdCard* SdBase< FsVolume >::card
| inlineinherited

Returns
  Pointer to SD card object.

## ◆ cardBegin() [1/2]

bool SdBase< FsVolume >::cardBegin | ( | SdioConfig | sdioConfig | ) |
| inlineinherited

Initialize SD card in SDIO mode.

Parameters

  [in] | sdioConfig | SDIO configuration.

Returns
  true for success or false for failure.

## ◆ cardBegin() [2/2]

bool SdBase< FsVolume >::cardBegin | ( | SdSpiConfig | spiConfig | ) |
| inlineinherited

Initialize SD card in SPI mode.

Parameters

  [in] | spiConfig | SPI configuration.

Returns
  true for success or false for failure.

## ◆ chdir() [1/2]

bool FsVolume::chdir | ( |  | ) |
| inlineinherited

Set volume working directory to root.

Returns
  true for success or false for failure.

## ◆ chdir() [2/2]

bool FsVolume::chdir | ( | const char * | path | ) |
| inlineinherited

Set volume working directory.

Parameters

  [in] | path | Path for volume working directory.

Returns
  true for success or false for failure.

## ◆ chvol()

void FsVolume::chvol | ( |  | ) |
| inlineinherited

Change global working volume to this volume.

## ◆ clusterCount()

uint32_t FsVolume::clusterCount | ( |  | ) | const
| inlineinherited

Returns
  The total number of clusters in the volume.

## ◆ dataStartSector()

uint32_t FsVolume::dataStartSector | ( |  | ) | const
| inlineinherited

Returns
  The logical sector number for the start of file data.

## ◆ end()

void FsVolume::end | ( |  | ) |
| inlineinherited

free dynamic memory and end access to volume

## ◆ errorHalt() [1/3]

void SdBase< FsVolume >::errorHalt | ( | print_t * | pr | ) |
| inlineinherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.

## ◆ errorHalt() [2/3]

void SdBase< FsVolume >::errorHalt | ( | print_t * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print msg and halt.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ errorHalt() [3/3]

void SdBase< FsVolume >::errorHalt | ( | print_t * | pr,
|  | const char * | msg
| ) |  |
| inlineinherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ errorPrint() [1/3]

void SdBase< FsVolume >::errorPrint | ( | Print * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print msg, any SD error code.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ errorPrint() [2/3]

void SdBase< FsVolume >::errorPrint | ( | print_t * | pr | ) |
| inlineinherited

Print SD errorCode and errorData.

Parameters

  [in] | pr | Print destination.

## ◆ errorPrint() [3/3]

void SdBase< FsVolume >::errorPrint | ( | print_t * | pr,
|  | char const * | msg
| ) |  |
| inlineinherited

Print msg, any SD error code.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ exists()

bool FsVolume::exists | ( | const char * | path | ) |
| inlineinherited

Test for the existence of a file in a directory

Parameters

  [in] | path | Path of the file to be tested for.

Returns
  true if the file exists else false.

## ◆ fatStartSector()

uint32_t FsVolume::fatStartSector | ( |  | ) | const
| inlineinherited

Returns
  The logical sector number for the start of the first FAT.

## ◆ fatType()

uint8_t FsVolume::fatType | ( |  | ) | const
| inlineinherited

Returns
  Partition type, FAT_TYPE_EXFAT, FAT_TYPE_FAT32, FAT_TYPE_FAT16, or zero for error.

## ◆ format()

bool SdFs::format | ( | print_t * | pr = `NULL` | ) |
| inline

Format a SD card FAT or exFAT.

Parameters

  [in] | pr | Optional Print information.

Returns
  true for success or false for failure.

## ◆ freeClusterCount()

uint32_t FsVolume::freeClusterCount | ( |  | ) | const
| inlineinherited

Returns
  the free cluster count.

## ◆ initErrorHalt() [1/3]

void SdBase< FsVolume >::initErrorHalt | ( | Print * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ initErrorHalt() [2/3]

void SdBase< FsVolume >::initErrorHalt | ( | print_t * | pr | ) |
| inlineinherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.

## ◆ initErrorHalt() [3/3]

void SdBase< FsVolume >::initErrorHalt | ( | print_t * | pr,
|  | const char * | msg
| ) |  |
| inlineinherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ initErrorPrint()

void SdBase< FsVolume >::initErrorPrint | ( | Print * | pr | ) |
| inlineinherited

Print error details after begin() fails.

Parameters

  [in] | pr | Print destination.

## ◆ isBusy()

bool FsVolume::isBusy | ( |  | ) |
| inlineinherited

Check for BlockDevice busy.

Returns
  true if busy else false.

## ◆ ls() [1/3]

bool FsVolume::ls | ( | print_t * | pr | ) |
| inlineinherited

List directory contents.

Parameters

  [in] | pr | Print object.

Returns
  true for success or false for failure.

## ◆ ls() [2/3]

bool FsVolume::ls | ( | print_t * | pr,
|  | const char * | path,
|  | uint8_t | flags
| ) |  |
| inherited

List the directory contents of a directory.

Parameters

  [in] | pr | Print stream for list.
  [in] | path | directory to list.
  [in] | flags | The inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Returns
  true for success or false for failure.

## ◆ ls() [3/3]

bool FsVolume::ls | ( | print_t * | pr,
|  | uint8_t | flags
| ) |  |
| inlineinherited

List directory contents.

Parameters

  [in] | pr | Print object.
  [in] | flags | The inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Returns
  true for success or false for failure.

## ◆ mkdir()

bool FsVolume::mkdir | ( | const char * | path,
|  | bool | pFlag = `true`
| ) |  |
| inlineinherited

Make a subdirectory in the volume root directory.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the subdirectory.
  [in] | pFlag | Create missing parent directories if true.

Returns
  true for success or false for failure.

## ◆ open()

FsFile FsVolume::open | ( | const char * | path,
|  | oflag_t | oflag = `0X00`
| ) |  |
| inherited

open a file

Parameters

  [in] | path | location of file to be opened.
  [in] | oflag | open flags.

Returns
  a FsBaseFile object.

## ◆ printFatType()

void SdBase< FsVolume >::printFatType | ( | print_t * | pr | ) |
| inlineinherited

Print volume FAT/exFAT type.

Parameters

  [in] | pr | Print destination.

## ◆ printSdError()

void SdBase< FsVolume >::printSdError | ( | print_t * | pr | ) |
| inlineinherited

Print error info and return.

Parameters

  [in] | pr | Print destination.

## ◆ remove()

bool FsVolume::remove | ( | const char * | path | ) |
| inlineinherited

Remove a file from the volume root directory.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the file.

Returns
  true for success or false for failure.

## ◆ rename()

bool FsVolume::rename | ( | const char * | oldPath,
|  | const char * | newPath
| ) |  |
| inlineinherited

Rename a file or subdirectory.

Parameters

  [in] | oldPath | Path name to the file or subdirectory to be renamed.
  [in] | newPath | New path name of the file or subdirectory.

The newPath object must not exist before the rename call.

The file to be renamed must not be open. The directory entry may be moved and file system corruption could occur if the file is accessed by a file object that was opened before the rename() call.

Returns
  true for success or false for failure.

## ◆ rmdir()

bool FsVolume::rmdir | ( | const char * | path | ) |
| inlineinherited

Remove a subdirectory from the volume's root directory.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the subdirectory.

The subdirectory file will be removed only if it is empty.

Returns
  true for success or false for failure.

## ◆ sdErrorCode()

uint8_t SdBase< FsVolume >::sdErrorCode
| inlineinherited

Returns
  SD card error code.

## ◆ sdErrorData()

uint8_t SdBase< FsVolume >::sdErrorData
| inlineinherited

Returns
  SD card error data.

## ◆ sectorsPerCluster()

uint32_t FsVolume::sectorsPerCluster | ( |  | ) | const
| inlineinherited

Returns
  The volume's cluster size in sectors.

## ◆ vol()

FsVolume * SdBase< FsVolume >::vol
| inlineinherited

Returns
  pointer to base volume

## ◆ volumeBegin()

bool SdBase< FsVolume >::volumeBegin
| inlineinherited

Initialize file system after call to cardBegin.

Returns
  true for success or false for failure.

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

- ArduinoSdFat/libraries/SdFat/src/SdFat.h