Skip to content

SdFile

Access FAT16 and FAT32 files on SD and SDHC cards.

詳細情報

メンバー

SdFile()

Create an instance of .

SdFile::SdFile(void)

clearUnbufferedRead()

writeError is set to true if an error occurs during a . Set writeError to false before calling and/or and check for true after calls to and/or .Cancel unbuffered reads for this file. See

void SdFile::clearUnbufferedRead(void)

close()

uint8_t SdFile::close(void)

戻り値

uint8_t

contiguousRange()

Check for contiguous file and return its raw block range.

uint8_t SdFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock)

引数

  • uint32_t * bgnBlock the first block address for the file.
  • uint32_t * endBlock the last block address for the file.

戻り値

uint8_t

createContiguous()

Create and open a new contiguous file of a specified size.

uint8_t SdFile::createContiguous(SdFile *dirFile, const char *fileName, uint32_t size)

引数

  • SdFile* dirFile The directory where the file will be created.
  • constchar * fileName A valid DOS 8.3 file name.
  • uint32_t size The desired file size.

戻り値

uint8_t

curCluster()

uint32_t SdFile::curCluster(void) const

戻り値

uint32_t The current cluster number for a file or directory.

curPosition()

uint32_t SdFile::curPosition(void) const

戻り値

uint32_t The current position for a file or directory.

dirBlock()

uint32_t SdFile::dirBlock(void) const

戻り値

uint32_t Address of the block that contains this file's directory.

dirEntry()

Return a files directory entry

uint8_t SdFile::dirEntry(dir_t *dir)

引数

  • dir_t* dir Location for return of the files directory entry.

戻り値

uint8_t

dirIndex()

uint8_t SdFile::dirIndex(void) const

戻り値

uint8_t Index of this file's directory in the block dirBlock.

fileSize()

uint32_t SdFile::fileSize(void) const

戻り値

uint32_t The total number of bytes in a file or directory.

firstCluster()

uint32_t SdFile::firstCluster(void) const

戻り値

uint32_t The first cluster number for a file or directory.

isDir()

uint8_t SdFile::isDir(void) const

戻り値

uint8_t True if this is a for a directory else false.

isFile()

uint8_t SdFile::isFile(void) const

戻り値

uint8_t True if this is a for a file else false.

isOpen()

uint8_t SdFile::isOpen(void) const

戻り値

uint8_t True if this is a for an open file/directory else false.

isSubDir()

uint8_t SdFile::isSubDir(void) const

戻り値

uint8_t True if this is a for a subdirectory else false.

isRoot()

uint8_t SdFile::isRoot(void) const

戻り値

uint8_t True if this is a for the root directory.

ls()

LS_R - Recursive list of subdirectories.

void SdFile::ls(uint8_t flags=0, uint8_t indent=0)

引数

  • uint8_t flags The inclusive OR of
  • uint8_t indent Amount of space before file name. Used for recursive list to indicate subdirectory level.

makeDir()

Make a new directory.

uint8_t SdFile::makeDir(SdFile *dir, const char *dirName)

引数

  • SdFile* dir An open SdFat instance for the directory that will containing the new directory.
  • constchar * dirName A valid 8.3 DOS name for the new directory.

戻り値

uint8_t

open()

Open a file by index.

uint8_t SdFile::open(SdFile *dirFile, uint16_t index, uint8_t oflag)

引数

  • SdFile* dirFile An open SdFat instance for the directory.
  • uint16_t index The of the directory entry for the file to be opened. The value for is (directory file position)/32.
  • uint8_t oflag Values for are constructed by a bitwise-inclusive OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC.

戻り値

uint8_t

open()

uint8_t SdFile::open(SdFile *dirFile, const char *fileName, uint8_t oflag)

引数

  • SdFile* dirFile An open SdFat instance for the directory containing the file to be opened.
  • constchar * fileName A valid 8.3 DOS name for a file to be opened.
  • uint8_t oflag Values for are constructed by a bitwise-inclusive OR of flags from the following list

戻り値

uint8_t

openRoot()

Open a volume's root directory.

uint8_t SdFile::openRoot(SdVolume *vol)

引数

  • SdVolume* vol The FAT volume containing the root directory to be opened.

戻り値

uint8_t

read()

int16_t SdFile::read(void)

戻り値

int16_t

read()

Read data from a file starting at the current position.

int16_t SdFile::read(void *buf, uint16_t nbyte)

引数

  • void * buf Pointer to the location that will receive the data.
  • uint16_t nbyte Maximum number of bytes to read.

戻り値

int16_t

readDir()

Read the next directory entry from a directory file.

int8_t SdFile::readDir(dir_t *dir)

引数

  • dir_t* dir The dir_t struct that will receive the data.

戻り値

int8_t

remove()

uint8_t SdFile::remove(void)

戻り値

uint8_t

rewind()

Set the file's current position to zero.

void SdFile::rewind(void)

rmDir()

uint8_t SdFile::rmDir(void)

戻り値

uint8_t

rmRfStar()

uint8_t SdFile::rmRfStar(void)

戻り値

uint8_t

seekCur()

Set the files position to current position + . See .

uint8_t SdFile::seekCur(uint32_t pos)

引数

  • uint32_t pos

戻り値

uint8_t

seekEnd()

Set the files current position to end of file. Useful to position a file for append. See .

uint8_t SdFile::seekEnd(void)

戻り値

uint8_t

seekSet()

Sets a file's position.

uint8_t SdFile::seekSet(uint32_t pos)

引数

  • uint32_t pos The new position in bytes from the beginning of the file.

戻り値

uint8_t

setUnbufferedRead()

Not recommended for normal applications.

void SdFile::setUnbufferedRead(void)

timestamp()

T_WRITE - Set the file's last write/modification date and time.

uint8_t SdFile::timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)

引数

  • uint8_t flag
  • uint16_t year Valid range 1980 - 2107 inclusive.
  • uint8_t month Valid range 1 - 12 inclusive.
  • uint8_t day Valid range 1 - 31 inclusive.
  • uint8_t hour Valid range 0 - 23 inclusive.
  • uint8_t minute Valid range 0 - 59 inclusive.
  • uint8_t second Valid range 0 - 59 inclusive

戻り値

uint8_t

sync()

uint8_t SdFile::sync(void)

戻り値

uint8_t

type()

uint8_t SdFile::type(void) const

戻り値

uint8_t

truncate()

Truncate a file to a specified length. The current file position will be maintained if it is less than or equal to otherwise it will be set to end of file.

uint8_t SdFile::truncate(uint32_t size)

引数

  • uint32_t size

戻り値

uint8_t

unbufferedRead()

uint8_t SdFile::unbufferedRead(void) const

戻り値

uint8_t Unbuffered read flag.

volume()

SdVolume* SdFile::volume(void) const

戻り値

SdVolume* that contains this file.

write()

Use SdFile::writeError to check for errors.

size_t SdFile::write(uint8_t b)

引数

  • uint8_t b

戻り値

size_t

write()

Write data to an open file.

size_t SdFile::write(const void *buf, uint16_t nbyte)

引数

  • constvoid * buf Pointer to the location of the data to be written.
  • uint16_t nbyte Number of bytes to write.

戻り値

size_t

write()

Use SdFile::writeError to check for errors.

size_t SdFile::write(const char *str)

引数

  • constchar * str

戻り値

size_t

contiguousRange()

uint8_t SdFile::contiguousRange(uint32_t &bgnBlock, uint32_t &endBlock)

引数

  • uint32_t & bgnBlock
  • uint32_t & endBlock

戻り値

uint8_t

createContiguous()

uint8_t SdFile::createContiguous(SdFile &dirFile, const char *fileName, uint32_t size)

引数

  • SdFile& dirFile
  • constchar * fileName
  • uint32_t size

戻り値

uint8_t

dirEntry()

uint8_t SdFile::dirEntry(dir_t &dir)

引数

  • dir_t& dir

戻り値

uint8_t

makeDir()

uint8_t SdFile::makeDir(SdFile &dir, const char *dirName)

引数

  • SdFile& dir
  • constchar * dirName

戻り値

uint8_t

open()

uint8_t SdFile::open(SdFile &dirFile, const char *fileName, uint8_t oflag)

引数

  • SdFile& dirFile
  • constchar * fileName
  • uint8_t oflag

戻り値

uint8_t

open()

uint8_t SdFile::open(SdFile &dirFile, const char *fileName)

引数

  • SdFile& dirFile
  • constchar * fileName

戻り値

uint8_t

open()

uint8_t SdFile::open(SdFile &dirFile, uint16_t index, uint8_t oflag)

引数

  • SdFile& dirFile
  • uint16_t index
  • uint8_t oflag

戻り値

uint8_t

openRoot()

uint8_t SdFile::openRoot(SdVolume &vol)

引数

  • SdVolume& vol

戻り値

uint8_t

readDir()

int8_t SdFile::readDir(dir_t &dir)

引数

  • dir_t& dir

戻り値

int8_t

dateTimeCallback()

See the function.

static void SdFile::dateTimeCallback(void(*dateTime)(uint16_t *date, uint16_t *time))

引数

  • timevoid()(uint16_t date, uint16_t *) dateTime The user's call back function. The callback function is of the form:

dateTimeCallbackCancel()

Cancel the date/time callback function.

static void SdFile::dateTimeCallbackCancel(void)

dirName()

Format the name field of into the 13 byte array in standard 8.3 short name format.

void SdFile::dirName(const dir_t &dir, char *name)

引数

  • const& dir The directory structure containing the name.
  • char * name A 13 byte char array for the formatted name.

printDirName()

Print the name field of a directory entry in 8.3 format to Serial.

void SdFile::printDirName(const dir_t &dir, uint8_t width)

引数

  • const& dir The directory structure containing the name.
  • uint8_t width Blank fill name if length is less than .

printFatDate()

Format is yyyy-mm-dd.

void SdFile::printFatDate(uint16_t fatDate)

引数

  • uint16_t fatDate The date field from a directory entry.

printFatTime()

Format is hh:mm:ss.

void SdFile::printFatTime(uint16_t fatTime)

引数

  • uint16_t fatTime The time field from a directory entry.

printTwoDigits()

Print a value as two digits to Serial.

void SdFile::printTwoDigits(uint8_t v)

引数

  • uint8_t v Value to be printed, 0 <= <= 99

remove()

The directory entry and all data for the file are deleted.

uint8_t SdFile::remove(SdFile *dirFile, const char *fileName)

引数

  • SdFile* dirFile The directory that contains the file.
  • constchar * fileName The name of the file to be removed.

戻り値

uint8_t

dateTimeCallback()

static void SdFile::dateTimeCallback(void(*dateTime)(uint16_t &date, uint16_t &time))

引数

  • timevoid(*)(uint16_t &date, uint16_t &) dateTime

remove()

static uint8_t SdFile::remove(SdFile &dirFile, const char *fileName)

引数

  • SdFile& dirFile
  • constchar * fileName

戻り値

uint8_t