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 (FsBlockDevice *blockDev, bool setCwv=true, uint8_t part=1)
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)
bool | chdir (const String &path)
void | chvol ()
uint32_t | clusterCount () const
uint32_t | dataStartSector () const
void | end ()
void | errorHalt ()
void | errorHalt (const __FlashStringHelper *msg)
void | errorHalt (const char *msg)
void | errorHalt (print_t *pr)
void | errorHalt (print_t *pr, const __FlashStringHelper *msg)
void | errorHalt (print_t *pr, const char *msg)
void | errorPrint (const __FlashStringHelper *msg)
void | errorPrint (const char *msg)
void | errorPrint (print_t *pr)
void | errorPrint (print_t *pr, char const *msg)
void | errorPrint (print_t *pr, const __FlashStringHelper *msg)
bool | exists (const char *path)
bool | exists (const String &path)
uint32_t | fatStartSector () const
uint8_t | fatType () const
bool | format (print_t *pr=NULL)
uint32_t | freeClusterCount ()
uint32_t | freeClusterCount () const
bool | hasDedicatedSpi ()
void | initErrorHalt ()
void | initErrorHalt (const __FlashStringHelper *msg)
void | initErrorHalt (const char *msg)
void | initErrorHalt (print_t *pr)
void | initErrorHalt (print_t *pr, const __FlashStringHelper *msg)
void | initErrorHalt (print_t *pr, const char *msg)
void | initErrorPrint ()
void | initErrorPrint (print_t *pr)
bool | isBusy ()
bool | isDedicatedSpi ()
bool | ls ()
bool | ls (const char *path, uint8_t flags=0)
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 | ls (uint8_t flags)
bool | mkdir (const char *path, bool pFlag=true)
bool | mkdir (const String &path, bool pFlag=true)
FsFile | open (const char *path, oflag_t oflag=0X00)
FsFile | open (const String &path, oflag_t oflag=0X00)
void | printFatType (print_t *pr)
void | printSdError (print_t *pr)
bool | remove (const char *path)
bool | remove (const String &path)
bool | rename (const char *oldPath, const char *newPath)
bool | rename (const String &oldPath, const String &newPath)
bool | rmdir (const char *path)
bool | rmdir (const String &path)
uint8_t | sdErrorCode ()
uint8_t | sdErrorData ()
uint32_t | sectorsPerCluster () const
bool | setDedicatedSpi (bool value)
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 | ( | FsBlockDevice * | blockDev,
|  | bool | setCwv = `true`,
|  | uint8_t | part = `1`
| ) |  |
| inherited

Initialize an FatVolume object.

Parameters

  [in] | blockDev | Device block driver.
  [in] | setCwv | Set current working volume if true.
  [in] | part | partition to initialize.

Returns
  true for success or false for failure.

## ◆ begin() [2/5]

bool SdBase< FsVolume , FsFormatter >::begin | ( | SdCsPin_t | csPin,
|  | uint32_t | maxSck
| ) |  |
| inline inherited

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 , FsFormatter >::begin | ( | SdCsPin_t | csPin = `SS` | ) |
| inline inherited

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 , FsFormatter >::begin | ( | SdioConfig | sdioConfig | ) |
| inline inherited

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 , FsFormatter >::begin | ( | SdSpiConfig | spiConfig | ) |
| inline inherited

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
| inline inherited

Returns
  the number of bytes in a cluster.

## ◆ card()

SdCard * SdBase< FsVolume , FsFormatter >::card | ( |  | ) |
| inline inherited

Returns
  Pointer to SD card object.

## ◆ cardBegin() [1/2]

bool SdBase< FsVolume , FsFormatter >::cardBegin | ( | SdioConfig | sdioConfig | ) |
| inline inherited

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 , FsFormatter >::cardBegin | ( | SdSpiConfig | spiConfig | ) |
| inline inherited

Initialize SD card in SPI mode.

Parameters

  [in] | spiConfig | SPI configuration.

Returns
  true for success or false for failure.

## ◆ chdir() [1/3]

bool FsVolume::chdir | ( |  | ) |
| inline inherited

Set volume working directory to root.

Returns
  true for success or false for failure.

## ◆ chdir() [2/3]

bool FsVolume::chdir | ( | const char * | path | ) |
| inline inherited

Set volume working directory.

Parameters

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

Returns
  true for success or false for failure.

## ◆ chdir() [3/3]

bool FsVolume::chdir | ( | const String & | path | ) |
| inline inherited

Set volume working directory.

Parameters

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

Returns
  true for success or false for failure.

## ◆ chvol()

void FsVolume::chvol | ( |  | ) |
| inline inherited

Change global working volume to this volume.

## ◆ clusterCount()

uint32_t FsVolume::clusterCount | ( |  | ) | const
| inline inherited

Returns
  The total number of clusters in the volume.

## ◆ dataStartSector()

uint32_t FsVolume::dataStartSector | ( |  | ) | const
| inline inherited

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

## ◆ end()

void SdBase< FsVolume , FsFormatter >::end | ( |  | ) |
| inline inherited

End use of card.

## ◆ errorHalt() [1/6]

void SdBase< FsVolume , FsFormatter >::errorHalt | ( |  | ) |
| inline inherited

Print error info to Serial and halt.

## ◆ errorHalt() [2/6]

void SdBase< FsVolume , FsFormatter >::errorHalt | ( | const __FlashStringHelper * | msg | ) |
| inline inherited

Print msg to Serial and halt.

Parameters

  [in] | msg | Message to print.

## ◆ errorHalt() [3/6]

void SdBase< FsVolume , FsFormatter >::errorHalt | ( | const char * | msg | ) |
| inline inherited

Print error info and halt.

Parameters

  [in] | msg | Message to print.

## ◆ errorHalt() [4/6]

void SdBase< FsVolume , FsFormatter >::errorHalt | ( | print_t * | pr | ) |
| inline inherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.

## ◆ errorHalt() [5/6]

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

Print msg and halt.

Parameters

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

## ◆ errorHalt() [6/6]

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

Print error info and halt.

Parameters

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

## ◆ errorPrint() [1/5]

void SdBase< FsVolume , FsFormatter >::errorPrint | ( | const __FlashStringHelper * | msg | ) |
| inline inherited

Print msg, any SD error code.

Parameters

  [in] | msg | Message to print.

## ◆ errorPrint() [2/5]

void SdBase< FsVolume , FsFormatter >::errorPrint | ( | const char * | msg | ) |
| inline inherited

Print msg, any SD error code.

Parameters

  [in] | msg | Message to print.

## ◆ errorPrint() [3/5]

void SdBase< FsVolume , FsFormatter >::errorPrint | ( | print_t * | pr | ) |
| inline inherited

Print SD errorCode and errorData.

Parameters

  [in] | pr | Print destination.

## ◆ errorPrint() [4/5]

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

Print msg, any SD error code.

Parameters

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

## ◆ errorPrint() [5/5]

void SdBase< FsVolume , FsFormatter >::errorPrint | ( | print_t * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inline inherited

Print msg, any SD error code.

Parameters

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

## ◆ exists() [1/2]

bool FsVolume::exists | ( | const char * | path | ) |
| inline inherited

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.

## ◆ exists() [2/2]

bool FsVolume::exists | ( | const String & | path | ) |
| inline inherited

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
| inline inherited

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

## ◆ fatType()

uint8_t FsVolume::fatType | ( |  | ) | const
| inline inherited

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

## ◆ format()

bool SdBase< FsVolume , FsFormatter >::format | ( | print_t * | pr = `NULL` | ) |
| inline inherited

Format SD card

Parameters

  [in] | pr | Print destination.

Returns
  true for success else false.

## ◆ freeClusterCount() [1/2]

uint32_t SdBase< FsVolume , FsFormatter >::freeClusterCount | ( |  | ) |
| inline inherited

Returns
  the free cluster count.

## ◆ freeClusterCount() [2/2]

uint32_t FsVolume::freeClusterCount | ( |  | ) | const
| inline inherited

Returns
  the free cluster count.

## ◆ hasDedicatedSpi()

bool SdBase< FsVolume , FsFormatter >::hasDedicatedSpi | ( |  | ) |
| inline inherited

Returns
  true if can be in dedicated SPI state

## ◆ initErrorHalt() [1/6]

void SdBase< FsVolume , FsFormatter >::initErrorHalt | ( |  | ) |
| inline inherited

Print error info and halt.

## ◆ initErrorHalt() [2/6]

void SdBase< FsVolume , FsFormatter >::initErrorHalt | ( | const __FlashStringHelper * | msg | ) |
| inline inherited

Print error info and halt.

Parameters

  [in] | msg | Message to print.

## ◆ initErrorHalt() [3/6]

void SdBase< FsVolume , FsFormatter >::initErrorHalt | ( | const char * | msg | ) |
| inline inherited

Print error info and halt.

Parameters

  [in] | msg | Message to print.

## ◆ initErrorHalt() [4/6]

void SdBase< FsVolume , FsFormatter >::initErrorHalt | ( | print_t * | pr | ) |
| inline inherited

Print error info and halt.

Parameters

  [in] | pr | Print destination.

## ◆ initErrorHalt() [5/6]

void SdBase< FsVolume , FsFormatter >::initErrorHalt | ( | print_t * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inline inherited

Print error info and halt.

Parameters

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

## ◆ initErrorHalt() [6/6]

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

Print error info and halt.

Parameters

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

## ◆ initErrorPrint() [1/2]

void SdBase< FsVolume , FsFormatter >::initErrorPrint | ( |  | ) |
| inline inherited

Print error details after begin() fails.

## ◆ initErrorPrint() [2/2]

void SdBase< FsVolume , FsFormatter >::initErrorPrint | ( | print_t * | pr | ) |
| inline inherited

Print error details after begin() fails.

Parameters

  [in] | pr | Print destination.

## ◆ isBusy()

bool FsVolume::isBusy | ( |  | ) |
| inline inherited

Check for device busy.

Returns
  true if busy else false.

## ◆ isDedicatedSpi()

bool SdBase< FsVolume , FsFormatter >::isDedicatedSpi | ( |  | ) |
| inline inherited

Returns
  true if in dedicated SPI state.

## ◆ ls() [1/6]

bool FsVolume::ls | ( |  | ) |
| inline inherited

List directory contents.

Returns
  true for success or false for failure.

## ◆ ls() [2/6]

bool FsVolume::ls | ( | const char * | path,
|  | uint8_t | flags = `0`
| ) |  |
| inline inherited

List the directory contents of a directory to Serial.

Parameters

  [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.
  true for success or false for failure.

## ◆ ls() [3/6]

bool FsVolume::ls | ( | print_t * | pr | ) |
| inline inherited

List directory contents.

Parameters

  [in] | pr | Print object.

Returns
  true for success or false for failure.

## ◆ ls() [4/6]

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() [5/6]

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

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.

## ◆ ls() [6/6]

bool FsVolume::ls | ( | uint8_t | flags | ) |
| inline inherited

List directory contents.

Parameters

  [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() [1/2]

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

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.

## ◆ mkdir() [2/2]

bool FsVolume::mkdir | ( | const String & | path,
|  | bool | pFlag = `true`
| ) |  |
| inline inherited

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() [1/2]

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.

## ◆ open() [2/2]

FsFile FsVolume::open | ( | const String & | 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 , FsFormatter >::printFatType | ( | print_t * | pr | ) |
| inline inherited

Print volume FAT/exFAT type.

Parameters

  [in] | pr | Print destination.

## ◆ printSdError()

void SdBase< FsVolume , FsFormatter >::printSdError | ( | print_t * | pr | ) |
| inline inherited

Print error info and return.

Parameters

  [in] | pr | Print destination.

## ◆ remove() [1/2]

bool FsVolume::remove | ( | const char * | path | ) |
| inline inherited

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.

## ◆ remove() [2/2]

bool FsVolume::remove | ( | const String & | path | ) |
| inline inherited

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() [1/2]

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

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.

## ◆ rename() [2/2]

bool FsVolume::rename | ( | const String & | oldPath,
|  | const String & | newPath
| ) |  |
| inline inherited

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() [1/2]

bool FsVolume::rmdir | ( | const char * | path | ) |
| inline inherited

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.

## ◆ rmdir() [2/2]

bool FsVolume::rmdir | ( | const String & | path | ) |
| inline inherited

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 , FsFormatter >::sdErrorCode | ( |  | ) |
| inline inherited

Returns
  SD card error code.

## ◆ sdErrorData()

uint8_t SdBase< FsVolume , FsFormatter >::sdErrorData | ( |  | ) |
| inline inherited

Returns
  SD card error data.

## ◆ sectorsPerCluster()

uint32_t FsVolume::sectorsPerCluster | ( |  | ) | const
| inline inherited

Returns
  The volume's cluster size in sectors.

## ◆ setDedicatedSpi()

bool SdBase< FsVolume , FsFormatter >::setDedicatedSpi | ( | bool | value | ) |
| inline inherited

Set SPI sharing state

Parameters

  [in] | value | desired state.

Returns
  true for success else false;

## ◆ vol()

FsVolume * SdBase< FsVolume , FsFormatter >::vol | ( |  | ) |
| inline inherited

Returns
  pointer to base volume

## ◆ volumeBegin()

bool SdBase< FsVolume , FsFormatter >::volumeBegin | ( |  | ) |
| inline inherited

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