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
ExFatFile Class Reference

Basic file class. More...

#include <ExFatFile.h>

Inherited by StreamFile< ExFatFile, uint64_t >.

Public Member Functions

 ExFatFile ()
 
 ExFatFile (const char *path, oflag_t oflag)
 
 ~ExFatFile ()
 
 operator bool ()
 
int available ()
 
uint64_t available64 ()
 
void clearError ()
 
void clearWriteError ()
 
bool close ()
 
bool contiguousRange (uint32_t *bgnSector, uint32_t *endSector)
 
uint64_t curPosition () const
 
uint64_t dataLength () const
 
uint32_t dirIndex () const
 
bool exists (const ExChar_t *path)
 
void fgetpos (fspos_t *pos) const
 
int fgets (char *str, int num, char *delim=nullptr)
 
uint64_t fileSize () const
 
uint32_t firstSector () const
 
void fsetpos (const fspos_t *pos)
 
void flush ()
 
bool getAccessDateTime (uint16_t *pdate, uint16_t *ptime)
 
bool getCreateDateTime (uint16_t *pdate, uint16_t *ptime)
 
uint8_t getError () const
 
bool getModifyDateTime (uint16_t *pdate, uint16_t *ptime)
 
size_t getName (ExChar_t *name, size_t size)
 
bool getWriteError () const
 
bool isBusy ()
 
bool isContiguous () const
 
bool isDir () const
 
bool isFile () const
 
bool isHidden () const
 
bool isOpen () const
 
bool isReadOnly () const
 
bool isRoot () const
 
bool isReadable () const
 
bool isSubDir () const
 
bool isWritable () const
 
bool ls (print_t *pr)
 
bool ls (print_t *pr, uint8_t flags, uint8_t indent=0)
 
bool mkdir (ExFatFile *parent, const ExChar_t *path, bool pFlag=true)
 
bool open (ExFatFile *dirFile, const ExChar_t *path, oflag_t oflag)
 
bool open (ExFatVolume *vol, const ExChar_t *path, int oflag)
 
bool open (ExFatFile *dirFile, uint32_t index, oflag_t oflag)
 
bool open (const ExChar_t *path, int oflag=O_RDONLY)
 
bool openNext (ExFatFile *dirFile, oflag_t oflag=O_RDONLY)
 
bool openRoot (ExFatVolume *vol)
 
int peek ()
 
bool preAllocate (uint64_t length)
 
size_t printAccessDateTime (print_t *pr)
 
size_t printCreateDateTime (print_t *pr)
 
size_t printField (double value, char term, uint8_t prec=2)
 
size_t printField (float value, char term, uint8_t prec=2)
 
template<typename Type >
size_t printField (Type value, char term)
 
size_t printFileSize (print_t *pr)
 
size_t printModifyDateTime (print_t *pr)
 
size_t printName (print_t *pr)
 
int read ()
 
int read (void *buf, size_t count)
 
bool remove ()
 
bool remove (const ExChar_t *path)
 
bool rename (const ExChar_t *newPath)
 
bool rename (ExFatFile *dirFile, const ExChar_t *newPath)
 
void rewind ()
 
bool rmdir ()
 
bool seekCur (int64_t offset)
 
bool seekEnd (int64_t offset=0)
 
bool seekSet (uint64_t pos)
 
bool sync ()
 
bool timestamp (uint8_t flags, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
 
bool truncate ()
 
bool truncate (uint64_t length)
 
uint64_t validLength () const
 
size_t write (const char *str)
 
size_t write (uint8_t b)
 
size_t write (const void *buf, size_t count)
 
bool exists (const char *path)
 
size_t getName (char *name, size_t size)
 
bool mkdir (ExFatFile *parent, const char *path, bool pFlag=true)
 
bool open (ExFatVolume *vol, const char *path, int oflag)
 
bool open (ExFatFile *dir, const char *path, int oflag)
 
bool open (const char *path, int oflag=O_RDONLY)
 
bool remove (const char *path)
 
bool rename (const char *newPath)
 
bool rename (ExFatFile *dirFile, const char *newPath)
 

Private Member Functions

bool addCluster ()
 
bool addDirCluster ()
 
uint8_t setCount () const
 
bool mkdir (ExFatFile *parent, ExName_t *fname)
 
bool openRootFile (ExFatFile *dir, const ExChar_t *name, uint8_t nameLength, oflag_t oflag)
 
bool open (ExFatFile *dirFile, ExName_t *fname, oflag_t oflag)
 
bool parsePathName (const ExChar_t *path, ExName_t *fname, const ExChar_t **ptr)
 
uint32_t curCluster () const
 
ExFatVolumevolume () const
 
bool syncDir ()
 

Private Attributes

uint64_t m_curPosition
 
uint64_t m_dataLength
 
uint64_t m_validLength
 
uint32_t m_curCluster
 
uint32_t m_firstCluster
 
ExFatVolumem_vol
 
DirPos_t m_dirPos
 
uint8_t m_setCount
 
uint8_t m_attributes = FILE_ATTR_CLOSED
 
uint8_t m_error = 0
 
uint8_t m_flags = 0
 

Static Private Attributes

static const uint8_t WRITE_ERROR = 0X1
 
static const uint8_t READ_ERROR = 0X2
 
static const uint8_t FILE_ATTR_CLOSED = 0
 
static const uint8_t FILE_ATTR_READ_ONLY = EXFAT_ATTRIB_READ_ONLY
 
static const uint8_t FILE_ATTR_HIDDEN = EXFAT_ATTRIB_HIDDEN
 
static const uint8_t FILE_ATTR_SYSTEM = EXFAT_ATTRIB_SYSTEM
 
static const uint8_t FILE_ATTR_FILE = 0X08
 
static const uint8_t FILE_ATTR_SUBDIR = EXFAT_ATTRIB_DIRECTORY
 
static const uint8_t FILE_ATTR_ARCHIVE = EXFAT_ATTRIB_ARCHIVE
 
static const uint8_t FILE_ATTR_ROOT = 0X40
 
static const uint8_t FILE_ATTR_DIR = FILE_ATTR_SUBDIR | FILE_ATTR_ROOT
 
static const uint8_t FILE_ATTR_COPY
 
static const uint8_t FILE_FLAG_READ = 0X01
 
static const uint8_t FILE_FLAG_WRITE = 0X02
 
static const uint8_t FILE_FLAG_APPEND = 0X08
 
static const uint8_t FILE_FLAG_CONTIGUOUS = 0X40
 
static const uint8_t FILE_FLAG_DIR_DIRTY = 0X80
 

Friends

class ExFatVolume
 

Detailed Description

Basic file class.

Constructor & Destructor Documentation

◆ ExFatFile() [1/2]

ExFatFile::ExFatFile ( )
inline

Create an instance.

◆ ExFatFile() [2/2]

ExFatFile::ExFatFile ( const char *  path,
oflag_t  oflag 
)
inline

Create a file object and open it in the current working directory.

Parameters
[in]pathA path for a file to be opened.
[in]oflagValues for oflag are constructed by a bitwise-inclusive OR of open flags. see FatFile::open(FatFile*, const char*, uint8_t).

◆ ~ExFatFile()

ExFatFile::~ExFatFile ( )
inline

Member Function Documentation

◆ addCluster()

bool ExFatFile::addCluster ( )
private

◆ addDirCluster()

bool ExFatFile::addDirCluster ( )
private

◆ available()

int ExFatFile::available ( )
inline
Returns
The number of bytes available from the current position to EOF for normal files. INT_MAX is returned for very large files.

available64() is recommended for very large files.

Zero is returned for directory files.

◆ available64()

uint64_t ExFatFile::available64 ( )
inline
Returns
The number of bytes available from the current position to EOF for normal files. Zero is returned for directory files.

◆ clearError()

void ExFatFile::clearError ( )
inline

Clear all error bits.

◆ clearWriteError()

void ExFatFile::clearWriteError ( )
inline

Clear writeError.

◆ close()

bool ExFatFile::close ( )

Close a file and force cached data and directory information to be written to the storage device.

Returns
true for success or false for failure.

◆ contiguousRange()

bool ExFatFile::contiguousRange ( uint32_t *  bgnSector,
uint32_t *  endSector 
)

Check for contiguous file and return its raw sector range.

Parameters
[out]bgnSectorthe first sector address for the file.
[out]endSectorthe last sector address for the file.

Parameters may be nullptr.

Returns
true for success or false for failure.

◆ curCluster()

uint32_t ExFatFile::curCluster ( ) const
inlineprivate

◆ curPosition()

uint64_t ExFatFile::curPosition ( ) const
inline
Returns
The current position for a file or directory.

◆ dataLength()

uint64_t ExFatFile::dataLength ( ) const
inline
Returns
Total data length for file.

◆ dirIndex()

uint32_t ExFatFile::dirIndex ( ) const
inline
Returns
Directory entry index.

◆ exists() [1/2]

bool ExFatFile::exists ( const char *  path)

◆ exists() [2/2]

bool ExFatFile::exists ( const ExChar_t path)
inline

Test for the existence of a file in a directory

Parameters
[in]pathPath of the file to be tested for.

The calling instance must be an open directory file.

dirFile.exists("TOFIND.TXT") searches for "TOFIND.TXT" in the directory dirFile.

Returns
true if the file exists else false.

◆ fgetpos()

void ExFatFile::fgetpos ( fspos_t pos) const

get position for streams

Parameters
[out]posstruct to receive position

◆ fgets()

int ExFatFile::fgets ( char *  str,
int  num,
char *  delim = nullptr 
)

Get a string from a file.

fgets() reads bytes from a file into the array pointed to by str, until num - 1 bytes are read, or a delimiter is read and transferred to str, or end-of-file is encountered. The string is then terminated with a null byte.

fgets() deletes CR, '\r', from the string. This insures only a '\n' terminates the string for Windows text files which use CRLF for newline.

Parameters
[out]strPointer to the array where the string is stored.
[in]numMaximum number of characters to be read (including the final null byte). Usually the length of the array str is used.
[in]delimOptional set of delimiters. The default is "\n".
Returns
For success fgets() returns the length of the string in str. If no data is read, fgets() returns zero for EOF or -1 if an error occurred.

◆ fileSize()

uint64_t ExFatFile::fileSize ( ) const
inline
Returns
The total number of bytes in a file.

◆ firstSector()

uint32_t ExFatFile::firstSector ( ) const
Returns
Address of first sector or zero for empty file.

◆ flush()

void ExFatFile::flush ( )
inline

Arduino name for sync()

◆ fsetpos()

void ExFatFile::fsetpos ( const fspos_t pos)

Set position for streams

Parameters
[in]posstruct with value for new position

◆ getAccessDateTime()

bool ExFatFile::getAccessDateTime ( uint16_t *  pdate,
uint16_t *  ptime 
)

Get a file's access date and time.

Parameters
[out]pdatePacked date for directory entry.
[out]ptimePacked time for directory entry.
Returns
true for success or false for failure.

◆ getCreateDateTime()

bool ExFatFile::getCreateDateTime ( uint16_t *  pdate,
uint16_t *  ptime 
)

Get a file's create date and time.

Parameters
[out]pdatePacked date for directory entry.
[out]ptimePacked time for directory entry.
Returns
true for success or false for failure.

◆ getError()

uint8_t ExFatFile::getError ( ) const
inline
Returns
All error bits.

◆ getModifyDateTime()

bool ExFatFile::getModifyDateTime ( uint16_t *  pdate,
uint16_t *  ptime 
)

Get a file's modify date and time.

Parameters
[out]pdatePacked date for directory entry.
[out]ptimePacked time for directory entry.
Returns
true for success or false for failure.

◆ getName() [1/2]

size_t ExFatFile::getName ( char *  name,
size_t  size 
)

◆ getName() [2/2]

size_t ExFatFile::getName ( ExChar_t name,
size_t  size 
)

Get a file's name followed by a zero byte.

Parameters
[out]nameAn array of characters for the file's name.
[in]sizeThe size of the array in characters.
Returns
the name length.

◆ getWriteError()

bool ExFatFile::getWriteError ( ) const
inline
Returns
value of writeError

◆ isBusy()

bool ExFatFile::isBusy ( )

Check for BlockDevice busy.

Returns
true if busy else false.

◆ isContiguous()

bool ExFatFile::isContiguous ( ) const
inline
Returns
True if the file is contiguous.

◆ isDir()

bool ExFatFile::isDir ( ) const
inline
Returns
True if this is a directory.

◆ isFile()

bool ExFatFile::isFile ( ) const
inline
Returns
True if this is a normal file.

◆ isHidden()

bool ExFatFile::isHidden ( ) const
inline
Returns
True if this is a hidden.

◆ isOpen()

bool ExFatFile::isOpen ( ) const
inline
Returns
true if the file is open.

◆ isReadable()

bool ExFatFile::isReadable ( ) const
inline
Returns
True file is readable.

◆ isReadOnly()

bool ExFatFile::isReadOnly ( ) const
inline
Returns
True if file is read-only

◆ isRoot()

bool ExFatFile::isRoot ( ) const
inline
Returns
True if this is the root directory.

◆ isSubDir()

bool ExFatFile::isSubDir ( ) const
inline
Returns
True if this is a subdirectory.

◆ isWritable()

bool ExFatFile::isWritable ( ) const
inline
Returns
True file is writable.

◆ ls() [1/2]

bool ExFatFile::ls ( print_t pr)

List directory contents.

Parameters
[in]prPrint stream for list.
Returns
true for success or false for failure.

◆ ls() [2/2]

bool ExFatFile::ls ( print_t pr,
uint8_t  flags,
uint8_t  indent = 0 
)

List directory contents.

Parameters
[in]prPrint stream for list.
[in]flagsThe inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Parameters
[in]indentAmount of space before file name. Used for recursive list to indicate subdirectory level.
Returns
true for success or false for failure.

◆ mkdir() [1/3]

bool ExFatFile::mkdir ( ExFatFile parent,
const char *  path,
bool  pFlag = true 
)

◆ mkdir() [2/3]

bool ExFatFile::mkdir ( ExFatFile parent,
const ExChar_t path,
bool  pFlag = true 
)

Make a new directory.

Parameters
[in]parentAn open directory file that will contain the new directory.
[in]pathA path with a valid name for the new directory.
[in]pFlagCreate missing parent directories if true.
Returns
true for success or false for failure.

◆ mkdir() [3/3]

bool ExFatFile::mkdir ( ExFatFile parent,
ExName_t fname 
)
private

◆ open() [1/8]

bool ExFatFile::open ( const char *  path,
int  oflag = O_RDONLY 
)

◆ open() [2/8]

bool ExFatFile::open ( const ExChar_t path,
int  oflag = O_RDONLY 
)

Open a file in the current working directory.

Parameters
[in]pathA path with a valid name for a file to be opened.
[in]oflagbitwise-inclusive OR of open flags. See see ExFatFile::open(ExFatFile*, const char*, uint8_t).
Returns
true for success or false for failure.

◆ open() [3/8]

bool ExFatFile::open ( ExFatFile dir,
const char *  path,
int  oflag 
)

◆ open() [4/8]

bool ExFatFile::open ( ExFatFile dirFile,
const ExChar_t path,
oflag_t  oflag 
)

Open a file or directory by name.

Parameters
[in]dirFileAn open directory containing the file to be opened.
[in]pathThe path for a file to be opened.
[in]oflagValues for oflag are constructed by a bitwise-inclusive OR of flags from the following list. Only one of O_RDONLY, O_READ, O_WRONLY, O_WRITE, or O_RDWR is allowed.

O_RDONLY - Open for reading.

O_READ - Same as O_RDONLY.

O_WRONLY - Open for writing.

O_WRITE - Same as O_WRONLY.

O_RDWR - Open for reading and writing.

O_APPEND - If set, the file offset shall be set to the end of the file prior to each write.

O_AT_END - Set the initial position at the end of the file.

O_CREAT - If the file exists, this flag has no effect except as noted under O_EXCL below. Otherwise, the file shall be created

O_EXCL - If O_CREAT and O_EXCL are set, open() shall fail if the file exists.

O_TRUNC - If the file exists and is a regular file, and the file is successfully opened and is not read only, its length shall be truncated to 0.

WARNING: A given file must not be opened by more than one file object or file corruption may occur.

Note
Directory files must be opened read only. Write and truncation is not allowed for directory files.
Returns
true for success or false for failure.

◆ open() [5/8]

bool ExFatFile::open ( ExFatFile dirFile,
ExName_t fname,
oflag_t  oflag 
)
inlineprivate

◆ open() [6/8]

bool ExFatFile::open ( ExFatFile dirFile,
uint32_t  index,
oflag_t  oflag 
)

Open a file by index.

Parameters
[in]dirFileAn open ExFatFile instance for the directory.
[in]indexThe index of the directory entry for the file to be opened. The value for index is (directory file position)/32.
[in]oflagbitwise-inclusive OR of open flags. See see ExFatFile::open(ExFatFile*, const ExChar_t*, uint8_t).

See open() by path for definition of flags.

Returns
true for success or false for failure.

◆ open() [7/8]

bool ExFatFile::open ( ExFatVolume vol,
const char *  path,
int  oflag 
)

◆ open() [8/8]

bool ExFatFile::open ( ExFatVolume vol,
const ExChar_t path,
int  oflag 
)

Open a file in the volume working directory.

Parameters
[in]volVolume where the file is located.
[in]pathwith a valid name for a file to be opened.
[in]oflagbitwise-inclusive OR of open flags. See see open(ExFatFile*, const char*, uint8_t).
Returns
true for success or false for failure.

◆ openNext()

bool ExFatFile::openNext ( ExFatFile dirFile,
oflag_t  oflag = O_RDONLY 
)

Open the next file or subdirectory in a directory.

Parameters
[in]dirFileAn open instance for the directory containing the file to be opened.
[in]oflagbitwise-inclusive OR of open flags. See see open(ExFatFile*, const char*, uint8_t).
Returns
true for success or false for failure.

◆ openRoot()

bool ExFatFile::openRoot ( ExFatVolume vol)

Open a volume's root directory.

Parameters
[in]volThe FAT volume containing the root directory to be opened.
Returns
true for success or false for failure.

◆ openRootFile()

bool ExFatFile::openRootFile ( ExFatFile dir,
const ExChar_t name,
uint8_t  nameLength,
oflag_t  oflag 
)
private

◆ operator bool()

ExFatFile::operator bool ( )
inline

The parenthesis operator.

Returns
true if a file is open.

◆ parsePathName()

bool ExFatFile::parsePathName ( const ExChar_t path,
ExName_t fname,
const ExChar_t **  ptr 
)
private

◆ peek()

int ExFatFile::peek ( )

Return the next available byte without consuming it.

Returns
The byte if no error and not at eof else -1;

◆ preAllocate()

bool ExFatFile::preAllocate ( uint64_t  length)

Allocate contiguous clusters to an empty file.

The file must be empty with no clusters allocated.

The file will have zero validLength and dataLength will equal the requested length.

Parameters
[in]lengthsize of allocated space in bytes.
Returns
true for success or false for failure.

◆ printAccessDateTime()

size_t ExFatFile::printAccessDateTime ( print_t pr)

Print a file's access date and time

Parameters
[in]prPrint stream for output.
Returns
true for success or false for failure.

◆ printCreateDateTime()

size_t ExFatFile::printCreateDateTime ( print_t pr)

Print a file's creation date and time

Parameters
[in]prPrint stream for output.
Returns
true for success or false for failure.

◆ printField() [1/3]

size_t ExFatFile::printField ( double  value,
char  term,
uint8_t  prec = 2 
)
inline

Print a number followed by a field terminator.

Parameters
[in]valueThe number to be printed.
[in]termThe field terminator. Use '\n' for CR LF.
[in]precNumber of digits after decimal point.
Returns
The number of bytes written or -1 if an error occurs.

◆ printField() [2/3]

size_t ExFatFile::printField ( float  value,
char  term,
uint8_t  prec = 2 
)
inline

Print a number followed by a field terminator.

Parameters
[in]valueThe number to be printed.
[in]termThe field terminator. Use '\n' for CR LF.
[in]precNumber of digits after decimal point.
Returns
The number of bytes written or -1 if an error occurs.

◆ printField() [3/3]

template<typename Type >
size_t ExFatFile::printField ( Type  value,
char  term 
)
inline

Print a number followed by a field terminator.

Parameters
[in]valueThe number to be printed.
[in]termThe field terminator. Use '\n' for CR LF.
Returns
The number of bytes written or -1 if an error occurs.

◆ printFileSize()

size_t ExFatFile::printFileSize ( print_t pr)

Print a file's size in bytes.

Parameters
[in]prPrtin stream for the output.
Returns
The number of bytes printed.

◆ printModifyDateTime()

size_t ExFatFile::printModifyDateTime ( print_t pr)

Print a file's modify date and time

Parameters
[in]prPrint stream for output.
Returns
true for success or false for failure.

◆ printName()

size_t ExFatFile::printName ( print_t pr)

Print a file's name

Parameters
[in]prPrint stream for output.
Returns
true for success or false for failure.

◆ read() [1/2]

int ExFatFile::read ( )
inline

Read the next byte from a file.

Returns
For success read returns the next byte in the file as an int. If an error occurs or end of file is reached -1 is returned.

◆ read() [2/2]

int ExFatFile::read ( void *  buf,
size_t  count 
)

Read data from a file starting at the current position.

Parameters
[out]bufPointer to the location that will receive the data.
[in]countMaximum number of bytes to read.
Returns
For success read() returns the number of bytes read. A value less than nbyte, including zero, will be returned if end of file is reached. If an error occurs, read() returns -1.

◆ remove() [1/3]

bool ExFatFile::remove ( )

Remove a file.

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

Note
This function should not be used to delete the 8.3 version of a file that has a long name. For example if a file has the long name "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT".
Returns
true for success or false for failure.

◆ remove() [2/3]

bool ExFatFile::remove ( const char *  path)

◆ remove() [3/3]

bool ExFatFile::remove ( const ExChar_t path)

Remove a file.

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

Parameters
[in]pathPath for the file to be removed.

Example use: dirFile.remove(filenameToRemove);

Note
This function should not be used to delete the 8.3 version of a file that has a long name. For example if a file has the long name "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT".
Returns
true for success or false for failure.

◆ rename() [1/4]

bool ExFatFile::rename ( const char *  newPath)

◆ rename() [2/4]

bool ExFatFile::rename ( const ExChar_t newPath)

Rename a file or subdirectory.

Parameters
[in]newPathNew path name for the file/directory.
Returns
true for success or false for failure.

◆ rename() [3/4]

bool ExFatFile::rename ( ExFatFile dirFile,
const char *  newPath 
)

◆ rename() [4/4]

bool ExFatFile::rename ( ExFatFile dirFile,
const ExChar_t newPath 
)

Rename a file or subdirectory.

Parameters
[in]dirFileDirectory for the new path.
[in]newPathNew path name for the file/directory.
Returns
true for success or false for failure.

◆ rewind()

void ExFatFile::rewind ( )
inline

Set the file's current position to zero.

◆ rmdir()

bool ExFatFile::rmdir ( )

Remove a directory file.

The directory file will be removed only if it is empty and is not the root directory. rmdir() follows DOS and Windows and ignores the read-only attribute for the directory.

Note
This function should not be used to delete the 8.3 version of a directory that has a long name. For example if a directory has the long name "New folder" you should not delete the 8.3 name "NEWFOL~1".
Returns
true for success or false for failure.

◆ seekCur()

bool ExFatFile::seekCur ( int64_t  offset)
inline

Set the files position to current position + pos. See seekSet().

Parameters
[in]offsetThe new position in bytes from the current position.
Returns
true for success or false for failure.

◆ seekEnd()

bool ExFatFile::seekEnd ( int64_t  offset = 0)
inline

Set the files position to end-of-file + offset. See seekSet(). Can't be used for directory files since file size is not defined.

Parameters
[in]offsetThe new position in bytes from end-of-file.
Returns
true for success or false for failure.

◆ seekSet()

bool ExFatFile::seekSet ( uint64_t  pos)

Sets a file's position.

Parameters
[in]posThe new position in bytes from the beginning of the file.
Returns
true for success or false for failure.

◆ setCount()

uint8_t ExFatFile::setCount ( ) const
inlineprivate

◆ sync()

bool ExFatFile::sync ( )

The sync() call causes all modified data and directory fields to be written to the storage device.

Returns
true for success or false for failure.

◆ syncDir()

bool ExFatFile::syncDir ( )
private

◆ timestamp()

bool ExFatFile::timestamp ( uint8_t  flags,
uint16_t  year,
uint8_t  month,
uint8_t  day,
uint8_t  hour,
uint8_t  minute,
uint8_t  second 
)

Truncate a file at the current file position.

Returns
true for success or false for failure. Set a file's timestamps in its directory entry.
Parameters
[in]flagsValues for flags are constructed by a bitwise-inclusive OR of flags from the following list

T_ACCESS - Set the file's last access date and time.

T_CREATE - Set the file's creation date and time.

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

Parameters
[in]yearValid range 1980 - 2107 inclusive.
[in]monthValid range 1 - 12 inclusive.
[in]dayValid range 1 - 31 inclusive.
[in]hourValid range 0 - 23 inclusive.
[in]minuteValid range 0 - 59 inclusive.
[in]secondValid range 0 - 59 inclusive
Note
It is possible to set an invalid date since there is no check for the number of days in a month.
Modify and access timestamps may be overwritten if a date time callback function has been set by dateTimeCallback().
Returns
true for success or false for failure.

◆ truncate() [1/2]

bool ExFatFile::truncate ( )

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

Returns
true for success or false for failure.

◆ truncate() [2/2]

bool ExFatFile::truncate ( uint64_t  length)
inline

Truncate a file to a specified length. The current file position will be set to end of file.

Parameters
[in]lengthThe desired length for the file.
Returns
true for success or false for failure.

◆ validLength()

uint64_t ExFatFile::validLength ( ) const
inline
Returns
The valid number of bytes in a file.

◆ volume()

ExFatVolume * ExFatFile::volume ( ) const
inlineprivate

◆ write() [1/3]

size_t ExFatFile::write ( const char *  str)
inline

Write a string to a file. Used by the Arduino Print class.

Parameters
[in]strPointer to the string. Use getWriteError to check for errors.
Returns
count of characters written for success or -1 for failure.

◆ write() [2/3]

size_t ExFatFile::write ( const void *  buf,
size_t  count 
)

Write data to an open file.

Note
Data is moved to the cache but may not be written to the storage device until sync() is called.
Parameters
[in]bufPointer to the location of the data to be written.
[in]countNumber of bytes to write.
Returns
For success write() returns the number of bytes written, always count.

◆ write() [3/3]

size_t ExFatFile::write ( uint8_t  b)
inline

Write a single byte.

Parameters
[in]bThe byte to be written.
Returns
+1 for success or zero for failure.

Friends And Related Symbol Documentation

◆ ExFatVolume

friend class ExFatVolume
friend

ExFatVolume allowed access to private members.

Member Data Documentation

◆ FILE_ATTR_ARCHIVE

const uint8_t ExFatFile::FILE_ATTR_ARCHIVE = EXFAT_ATTRIB_ARCHIVE
staticprivate

◆ FILE_ATTR_CLOSED

const uint8_t ExFatFile::FILE_ATTR_CLOSED = 0
staticprivate

This file has not been opened.

◆ FILE_ATTR_COPY

const uint8_t ExFatFile::FILE_ATTR_COPY
staticprivate
Initial value:
const uint8_t EXFAT_ATTRIB_DIRECTORY
Definition FsStructs.h:360
const uint8_t EXFAT_ATTRIB_READ_ONLY
Definition FsStructs.h:356
const uint8_t EXFAT_ATTRIB_ARCHIVE
Definition FsStructs.h:361
const uint8_t EXFAT_ATTRIB_HIDDEN
Definition FsStructs.h:357
const uint8_t EXFAT_ATTRIB_SYSTEM
Definition FsStructs.h:358

Attributes to copy from directory entry

◆ FILE_ATTR_DIR

const uint8_t ExFatFile::FILE_ATTR_DIR = FILE_ATTR_SUBDIR | FILE_ATTR_ROOT
staticprivate

Directory type bits

◆ FILE_ATTR_FILE

const uint8_t ExFatFile::FILE_ATTR_FILE = 0X08
staticprivate

Entry for normal data file

◆ FILE_ATTR_HIDDEN

const uint8_t ExFatFile::FILE_ATTR_HIDDEN = EXFAT_ATTRIB_HIDDEN
staticprivate

File should be hidden in directory listings.

◆ FILE_ATTR_READ_ONLY

const uint8_t ExFatFile::FILE_ATTR_READ_ONLY = EXFAT_ATTRIB_READ_ONLY
staticprivate

File is read-only.

◆ FILE_ATTR_ROOT

const uint8_t ExFatFile::FILE_ATTR_ROOT = 0X40
staticprivate

Root directory

◆ FILE_ATTR_SUBDIR

const uint8_t ExFatFile::FILE_ATTR_SUBDIR = EXFAT_ATTRIB_DIRECTORY
staticprivate

Entry is for a subdirectory

◆ FILE_ATTR_SYSTEM

const uint8_t ExFatFile::FILE_ATTR_SYSTEM = EXFAT_ATTRIB_SYSTEM
staticprivate

Entry is for a system file.

◆ FILE_FLAG_APPEND

const uint8_t ExFatFile::FILE_FLAG_APPEND = 0X08
staticprivate

◆ FILE_FLAG_CONTIGUOUS

const uint8_t ExFatFile::FILE_FLAG_CONTIGUOUS = 0X40
staticprivate

◆ FILE_FLAG_DIR_DIRTY

const uint8_t ExFatFile::FILE_FLAG_DIR_DIRTY = 0X80
staticprivate

◆ FILE_FLAG_READ

const uint8_t ExFatFile::FILE_FLAG_READ = 0X01
staticprivate

◆ FILE_FLAG_WRITE

const uint8_t ExFatFile::FILE_FLAG_WRITE = 0X02
staticprivate

◆ m_attributes

uint8_t ExFatFile::m_attributes = FILE_ATTR_CLOSED
private

◆ m_curCluster

uint32_t ExFatFile::m_curCluster
private

◆ m_curPosition

uint64_t ExFatFile::m_curPosition
private

◆ m_dataLength

uint64_t ExFatFile::m_dataLength
private

◆ m_dirPos

DirPos_t ExFatFile::m_dirPos
private

◆ m_error

uint8_t ExFatFile::m_error = 0
private

◆ m_firstCluster

uint32_t ExFatFile::m_firstCluster
private

◆ m_flags

uint8_t ExFatFile::m_flags = 0
private

◆ m_setCount

uint8_t ExFatFile::m_setCount
private

◆ m_validLength

uint64_t ExFatFile::m_validLength
private

◆ m_vol

ExFatVolume* ExFatFile::m_vol
private

◆ READ_ERROR

const uint8_t ExFatFile::READ_ERROR = 0X2
staticprivate

◆ WRITE_ERROR

const uint8_t ExFatFile::WRITE_ERROR = 0X1
staticprivate

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