| SdFat
    | 
Basic file class. More...
#include <ExFatFile.h>

| Public Member Functions | |
| 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 () | 
| uint32_t | dirIndex () | 
| ExFatFile () | |
| bool | exists (const ExChar_t *path) | 
| void | fgetpos (fspos_t *pos) | 
| int | fgets (char *str, int num, char *delim=NULL) | 
| uint64_t | fileSize () | 
| uint32_t | firstSector () | 
| void | flush () | 
| void | fsetpos (const fspos_t *pos) | 
| bool | getAccessDateTime (uint16_t *pdate, uint16_t *ptime) | 
| bool | getCreateDateTime (uint16_t *pdate, uint16_t *ptime) | 
| uint8_t | getError () | 
| bool | getModifyDateTime (uint16_t *pdate, uint16_t *ptime) | 
| size_t | getName (ExChar_t *name, size_t size) | 
| bool | getWriteError () | 
| bool | isContiguous () const | 
| bool | isDir () const | 
| bool | isFile () const | 
| bool | isHidden () const | 
| bool | isOpen () const | 
| bool | isReadable () const | 
| bool | isReadOnly () const | 
| bool | isRoot () 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 (const ExChar_t *path, int oflag=0X00) | 
| bool | open (ExFatFile *dirFile, const ExChar_t *path, oflag_t oflag) | 
| bool | open (ExFatFile *dirFile, uint32_t index, oflag_t oflag) | 
| bool | open (ExFatVolume *vol, const ExChar_t *path, int oflag) | 
| bool | openNext (ExFatFile *dirFile, oflag_t oflag=0X00) | 
| bool | openRoot (ExFatVolume *vol) | 
| operator bool () | |
| 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 () | 
| size_t | write (const char *str) | 
| size_t | write (const void *buf, size_t count) | 
| size_t | write (uint8_t b) | 
| Friends | |
| class | ExFatVolume | 
Basic file class.
| 
 | inline | 
Create an instance.
| 
 | inline | 
available64() is recommended for very large files.
Zero is returned for directory files.
| 
 | inline | 
| 
 | inline | 
Clear all error bits.
| 
 | inline | 
Clear writeError.
| bool ExFatFile::close | ( | ) | 
Close a file and force cached data and directory information to be written to the storage device.
| bool ExFatFile::contiguousRange | ( | uint32_t * | bgnSector, | 
| uint32_t * | endSector | ||
| ) | 
Check for contiguous file and return its raw sector range.
| [out] | bgnSector | the first sector address for the file. | 
| [out] | endSector | the last sector address for the file. | 
Parameters may be nullptr.
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
Test for the existence of a file in a directory
| [in] | path | Path 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.
| void ExFatFile::fgetpos | ( | fspos_t * | pos | ) | 
get position for streams
| [out] | pos | struct to receive position | 
| int ExFatFile::fgets | ( | char * | str, | 
| int | num, | ||
| char * | delim = NULL | ||
| ) | 
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.
| [out] | str | Pointer to the array where the string is stored. | 
| [in] | num | Maximum number of characters to be read (including the final null byte). Usually the length of the array str is used. | 
| [in] | delim | Optional set of delimiters. The default is "\n". | 
| 
 | inline | 
| uint32_t ExFatFile::firstSector | ( | ) | 
| 
 | inline | 
Arduino name for sync()
| void ExFatFile::fsetpos | ( | const fspos_t * | pos | ) | 
Set position for streams
| [in] | pos | struct with value for new position | 
| bool ExFatFile::getAccessDateTime | ( | uint16_t * | pdate, | 
| uint16_t * | ptime | ||
| ) | 
Get a file's access date and time.
| [out] | pdate | Packed date for directory entry. | 
| [out] | ptime | Packed time for directory entry. | 
| bool ExFatFile::getCreateDateTime | ( | uint16_t * | pdate, | 
| uint16_t * | ptime | ||
| ) | 
Get a file's create date and time.
| [out] | pdate | Packed date for directory entry. | 
| [out] | ptime | Packed time for directory entry. | 
| 
 | inline | 
| bool ExFatFile::getModifyDateTime | ( | uint16_t * | pdate, | 
| uint16_t * | ptime | ||
| ) | 
Get a file's modify date and time.
| [out] | pdate | Packed date for directory entry. | 
| [out] | ptime | Packed time for directory entry. | 
| size_t ExFatFile::getName | ( | ExChar_t * | name, | 
| size_t | size | ||
| ) | 
Get a file's name followed by a zero byte.
| [out] | name | An array of characters for the file's name. | 
| [in] | size | The size of the array in characters. | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| 
 | inline | 
| bool ExFatFile::ls | ( | print_t * | pr | ) | 
List directory contents.
| [in] | pr | Print stream for list. | 
| bool ExFatFile::ls | ( | print_t * | pr, | 
| uint8_t | flags, | ||
| uint8_t | indent = 0 | ||
| ) | 
List directory contents.
| [in] | pr | Print stream for list. | 
| [in] | flags | The inclusive OR of | 
LS_DATE - Print file modification date
LS_SIZE - Print file size.
LS_R - Recursive list of subdirectories.
| [in] | indent | Amount of space before file name. Used for recursive list to indicate subdirectory level. | 
| bool ExFatFile::mkdir | ( | ExFatFile * | parent, | 
| const ExChar_t * | path, | ||
| bool | pFlag = true | ||
| ) | 
Make a new directory.
| [in] | parent | An open directory file that will contain the new directory. | 
| [in] | path | A path with a valid name for the new directory. | 
| [in] | pFlag | Create missing parent directories if true. | 
| bool ExFatFile::open | ( | const ExChar_t * | path, | 
| int | oflag = 0X00 | ||
| ) | 
Open a file in the current working directory.
| [in] | path | A path with a valid name for a file to be opened. | 
| [in] | oflag | bitwise-inclusive OR of open flags. See see ExFatFile::open(ExFatFile*, const char*, uint8_t). | 
| bool ExFatFile::open | ( | ExFatFile * | dirFile, | 
| const ExChar_t * | path, | ||
| oflag_t | oflag | ||
| ) | 
Open a file or directory by name.
| [in] | dirFile | An open directory containing the file to be opened. | 
| [in] | path | The path for a file to be opened. | 
| [in] | oflag | Values 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.
| bool ExFatFile::open | ( | ExFatFile * | dirFile, | 
| uint32_t | index, | ||
| oflag_t | oflag | ||
| ) | 
Open a file by index.
| [in] | dirFile | An open ExFatFile instance for the directory. | 
| [in] | index | The index of the directory entry for the file to be opened. The value for index is (directory file position)/32. | 
| [in] | oflag | bitwise-inclusive OR of open flags. See see ExFatFile::open(ExFatFile*, const ExChar_t*, uint8_t). | 
See open() by path for definition of flags.
| bool ExFatFile::open | ( | ExFatVolume * | vol, | 
| const ExChar_t * | path, | ||
| int | oflag | ||
| ) | 
Open a file in the volume working directory.
| [in] | vol | Volume where the file is located. | 
| [in] | path | with a valid name for a file to be opened. | 
| [in] | oflag | bitwise-inclusive OR of open flags. See see open(ExFatFile*, const char*, uint8_t). | 
| bool ExFatFile::openNext | ( | ExFatFile * | dirFile, | 
| oflag_t | oflag = 0X00 | ||
| ) | 
Open the next file or subdirectory in a directory.
| [in] | dirFile | An open instance for the directory containing the file to be opened. | 
| [in] | oflag | bitwise-inclusive OR of open flags. See see open(ExFatFile*, const char*, uint8_t). | 
| bool ExFatFile::openRoot | ( | ExFatVolume * | vol | ) | 
Open a volume's root directory.
| [in] | vol | The FAT volume containing the root directory to be opened. | 
| 
 | inline | 
The parenthesis operator.
| int ExFatFile::peek | ( | ) | 
Return the next available byte without consuming it.
| 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.
| [in] | length | size of allocated space in bytes. | 
| size_t ExFatFile::printAccessDateTime | ( | print_t * | pr | ) | 
Print a file's access date and time
| [in] | pr | Print stream for output. | 
| size_t ExFatFile::printCreateDateTime | ( | print_t * | pr | ) | 
Print a file's creation date and time
| [in] | pr | Print stream for output. | 
| 
 | inline | 
Print a number followed by a field terminator.
| [in] | value | The number to be printed. | 
| [in] | term | The field terminator. Use '\n' for CR LF. | 
| [in] | prec | Number of digits after decimal point. | 
| 
 | inline | 
Print a number followed by a field terminator.
| [in] | value | The number to be printed. | 
| [in] | term | The field terminator. Use '\n' for CR LF. | 
| [in] | prec | Number of digits after decimal point. | 
| 
 | inline | 
Print a number followed by a field terminator.
| [in] | value | The number to be printed. | 
| [in] | term | The field terminator. Use '\n' for CR LF. | 
| size_t ExFatFile::printFileSize | ( | print_t * | pr | ) | 
Print a file's size in bytes.
| [in] | pr | Prtin stream for the output. | 
| size_t ExFatFile::printModifyDateTime | ( | print_t * | pr | ) | 
Print a file's modify date and time
| [in] | pr | Print stream for output. | 
| size_t ExFatFile::printName | ( | print_t * | pr | ) | 
Print a file's name
| [in] | pr | Print stream for output. | 
| 
 | inline | 
Read the next byte from a file.
| int ExFatFile::read | ( | void * | buf, | 
| size_t | count | ||
| ) | 
Read data from a file starting at the current position.
| [out] | buf | Pointer to the location that will receive the data. | 
| [in] | count | Maximum number of bytes to read. | 
| bool ExFatFile::remove | ( | ) | 
Remove a file.
The directory entry and all data for the file are deleted.
| bool ExFatFile::remove | ( | const ExChar_t * | path | ) | 
Remove a file.
The directory entry and all data for the file are deleted.
| [in] | path | Path for the file to be removed. | 
Example use: dirFile.remove(filenameToRemove);
| bool ExFatFile::rename | ( | const ExChar_t * | newPath | ) | 
Rename a file or subdirectory.
| [in] | newPath | New path name for the file/directory. | 
| bool ExFatFile::rename | ( | ExFatFile * | dirFile, | 
| const ExChar_t * | newPath | ||
| ) | 
Rename a file or subdirectory.
| [in] | dirFile | Directory for the new path. | 
| [in] | newPath | New path name for the file/directory. | 
| 
 | inline | 
Set the file's current position to zero.
| 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.
| 
 | inline | 
Set the files position to current position + pos. See seekSet().
| [in] | offset | The new position in bytes from the current position. | 
| 
 | 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.
| [in] | offset | The new position in bytes from end-of-file. | 
| bool ExFatFile::seekSet | ( | uint64_t | pos | ) | 
Sets a file's position.
| [in] | pos | The new position in bytes from the beginning of the file. | 
| bool ExFatFile::sync | ( | ) | 
The sync() call causes all modified data and directory fields to be written to the storage device.
| 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.
| [in] | flags | Values 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.
| [in] | year | Valid range 1980 - 2107 inclusive. | 
| [in] | month | Valid range 1 - 12 inclusive. | 
| [in] | day | Valid range 1 - 31 inclusive. | 
| [in] | hour | Valid range 0 - 23 inclusive. | 
| [in] | minute | Valid range 0 - 59 inclusive. | 
| [in] | second | Valid range 0 - 59 inclusive | 
| 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.
| 
 | inline | 
Truncate a file to a specified length. The current file position will be set to end of file.
| [in] | length | The desired length for the file. | 
| 
 | inline | 
| 
 | inline | 
Write a string to a file. Used by the Arduino Print class.
| [in] | str | Pointer to the string. Use getWriteError to check for errors. | 
| size_t ExFatFile::write | ( | const void * | buf, | 
| size_t | count | ||
| ) | 
Write data to an open file.
| [in] | buf | Pointer to the location of the data to be written. | 
| [in] | count | Number of bytes to write. | 
| 
 | inline | 
Write a single byte.
| [in] | b | The byte to be written. | 
| 
 | friend | 
ExFatVolume allowed access to private members.
 1.8.16
 1.8.16