SdFat
|
FAT16/FAT32 file with Arduino Stream. More...
#include <FatFile.h>
Public Member Functions | |
int | available () |
uint32_t | available32 () |
void | clearError () |
void | clearWriteError () |
bool | close () |
bool | contiguousRange (uint32_t *bgnSector, uint32_t *endSector) |
bool | createContiguous (const char *path, uint32_t size) |
bool | createContiguous (FatFile *dirFile, const char *path, uint32_t size) |
uint32_t | curCluster () const |
uint32_t | curPosition () const |
bool | dirEntry (DirFat_t *dir) |
uint16_t | dirIndex () |
uint32_t | dirSize () |
void | dmpFile (print_t *pr, uint32_t pos, size_t n) |
bool | exists (const char *path) |
void | fgetpos (fspos_t *pos) |
int | fgets (char *str, int num, char *delim=NULL) |
uint32_t | fileSize () const |
uint32_t | firstBlock () const |
uint32_t | firstSector () const |
void | flush () |
void | fsetpos (const fspos_t *pos) |
uint8_t | getError () |
bool | getName (char *name, size_t size) |
bool | getSFN (char *name) |
bool | getWriteError () |
bool | isContiguous () const |
bool | isDir () const |
bool | isDirectory () |
bool | isFile () const |
bool | isHidden () const |
bool | isLFN () const |
bool | isOpen () const |
bool | isReadable () const |
bool | isReadOnly () const |
bool | isRoot () const |
bool | isRoot32 () const |
bool | isRootFixed () const |
bool | isSubDir () const |
bool | isSystem () const |
bool | isWritable () const |
bool | ls (print_t *pr, uint8_t flags=0, uint8_t indent=0) |
bool | ls (uint8_t flags=0) |
bool | mkdir (FatFile *dir, const char *path, bool pFlag=true) |
const char * | name () const |
bool | open (const char *path, oflag_t oflag=0X00) |
bool | open (FatFile *dirFile, const char *path, oflag_t oflag) |
bool | open (FatFile *dirFile, uint16_t index, oflag_t oflag) |
bool | open (FatVolume *vol, const char *path, oflag_t oflag) |
bool | openNext (FatFile *dirFile, oflag_t oflag=0X00) |
File32 | openNextFile (oflag_t oflag=0X00) |
bool | openRoot (FatVolume *vol) |
operator bool () | |
int | peek () |
uint32_t | position () |
bool | preAllocate (uint32_t length) |
size_t | printAccessDate (print_t *pr) |
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 () |
size_t | printName (print_t *pr) |
size_t | printSFN (print_t *pr) |
int | read () |
int | read (void *buf, size_t count) |
int8_t | readDir (DirFat_t *dir) |
bool | remove () |
bool | remove (const char *path) |
bool | rename (const char *newPath) |
bool | rename (FatFile *dirFile, const char *newPath) |
void | rewind () |
void | rewindDirectory () |
bool | rmdir () |
bool | rmRfStar () |
bool | seek (uint32_t pos) |
bool | seekCur (int32_t offset) |
bool | seekEnd (int32_t offset=0) |
bool | seekSet (uint32_t pos) |
uint32_t | size () |
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 (uint32_t length) |
size_t | write (const char *str) |
size_t | write (const uint8_t *buffer, size_t size) |
size_t | write (const void *buf, size_t count) |
size_t | write (uint8_t b) |
Static Public Member Functions | |
static bool | legal83Char (uint8_t c) |
static void | printFatDate (print_t *pr, uint16_t fatDate) |
static void | printFatTime (print_t *pr, uint16_t fatTime) |
FAT16/FAT32 file with Arduino Stream.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Clear all error bits.
|
inlineinherited |
Set writeError to zero
|
inherited |
Close a file and force cached data and directory information to be written to the storage device.
|
inherited |
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. |
|
inherited |
Create and open a new contiguous file of a specified size.
[in] | path | A path with a validfile name. |
[in] | size | The desired file size. |
|
inherited |
Create and open a new contiguous file of a specified size.
[in] | dirFile | The directory where the file will be created. |
[in] | path | A path with a validfile name. |
[in] | size | The desired file size. |
|
inlineinherited |
|
inlineinherited |
|
inherited |
Return a file's directory entry.
[out] | dir | Location for return of the file's directory entry. |
|
inlineinherited |
|
inherited |
|
inherited |
Dump file in Hex
[in] | pr | Print stream for list. |
[in] | pos | Start position in file. |
[in] | n | number of locations to dump. |
|
inlineinherited |
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.
|
inherited |
get position for streams
[out] | pos | struct to receive position |
|
inherited |
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". |
|
inlineinherited |
|
inlineinherited |
|
inherited |
|
inlineinherited |
Ensure that any bytes written to the file are saved to the SD card.
|
inherited |
set position for streams
[in] | pos | struct with value for new position |
|
inlineinherited |
|
inherited |
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 bytes. The array must be at least 13 bytes long. The file's name will be truncated if the file's name is too long. |
|
inherited |
Get a file's Short File Name followed by a zero byte.
[out] | name | An array of characters for the file's name. The array must be at least 13 bytes long. |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
This function reports if the current file is a directory or not.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlinestaticinherited |
Check for a legal 8.3 character.
[in] | c | Character to be checked. |
|
inherited |
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. |
|
inlineinherited |
List directory contents.
[in] | flags | The inclusive OR of |
LS_DATE - Print file modification date
LS_SIZE - Print file size.
LS_R - Recursive list of subdirectories.
|
inherited |
Make a new directory.
[in] | dir | An open FatFile instance for the directory 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. |
|
inlineinherited |
No longer implemented due to Long File Names.
Use getName(char* name, size_t size).
|
inherited |
Open a file in the current working volume.
[in] | path | A path with a valid name for a file to be opened. |
[in] | oflag | bitwise-inclusive OR of open flags. See see FatFile::open(FatFile*, const char*, uint8_t). |
|
inherited |
Open a file or directory by name.
[in] | dirFile | An open FatFile instance for the directory containing the file to be opened. |
[in] | path | A path with a valid name 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 FatFile object or file corruption may occur.
|
inherited |
Open a file by index.
[in] | dirFile | An open FatFile 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 FatFile::open(FatFile*, const char*, uint8_t). |
See open() by path for definition of flags.
|
inherited |
Open a file in the volume root 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 FatFile::open(FatFile*, const char*, uint8_t). |
|
inherited |
Open the next file or subdirectory in a directory.
[in] | dirFile | An open FatFile instance for the directory containing the file to be opened. |
[in] | oflag | bitwise-inclusive OR of open flags. See see FatFile::open(FatFile*, const char*, uint8_t). |
|
inline |
Opens the next file or folder in a directory.
[in] | oflag | open flags. |
|
inherited |
Open a volume's root directory.
[in] | vol | The FAT volume containing the root directory to be opened. |
|
inlineinherited |
The parenthesis operator.
|
inlineinherited |
Return the next available byte without consuming it.
|
inlineinherited |
|
inherited |
Allocate contiguous clusters to an empty file.
The file must be empty with no clusters allocated.
The file will contain uninitialized data.
[in] | length | size of the file in bytes. |
|
inherited |
Print a file's access date
[in] | pr | Print stream for output. |
|
inlineinherited |
Print a file's access date
[in] | pr | Print stream for output. |
|
inherited |
Print a file's creation date and time
[in] | pr | Print stream for output. |
|
staticinherited |
Print a directory date field.
Format is yyyy-mm-dd.
[in] | pr | Print stream for output. |
[in] | fatDate | The date field from a directory entry. |
|
staticinherited |
Print a directory time field.
Format is hh:mm:ss.
[in] | pr | Print stream for output. |
[in] | fatTime | The time field from a directory entry. |
|
inlineinherited |
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. |
|
inlineinherited |
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. |
|
inlineinherited |
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. |
|
inherited |
Print a file's size.
[in] | pr | Print stream for output. |
|
inherited |
Print a file's modify date and time
[in] | pr | Print stream for output. |
|
inlineinherited |
Print a file's name.
|
inherited |
Print a file's name
[in] | pr | Print stream for output. |
|
inherited |
Print a file's Short File Name.
[in] | pr | Print stream for output. |
|
inlineinherited |
Read the next byte from a file.
|
inherited |
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. |
|
inherited |
Read the next directory entry from a directory file.
[out] | dir | The DirFat_t struct that will receive the data. |
|
inherited |
Remove a file.
The directory entry and all data for the file are deleted.
|
inherited |
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);
|
inherited |
Rename a file or subdirectory.
[in] | newPath | New path name for the file/directory. |
|
inherited |
Rename a file or subdirectory.
[in] | dirFile | Directory for the new path. |
[in] | newPath | New path name for the file/directory. |
|
inlineinherited |
Set the file's current position to zero.
|
inlineinherited |
Rewind a file if it is a directory
|
inherited |
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.
|
inherited |
Recursively delete a directory and all contained files.
This is like the Unix/Linux 'rm -rf *' if called with the root directory hence the name.
Warning - This will remove all contents of the directory including subdirectories. The directory will then be removed if it is not root. The read-only attribute for files will be ignored.
|
inlineinherited |
Seek to a new position in the file, which must be between 0 and the size of the file (inclusive).
[in] | pos | the new file position. |
|
inlineinherited |
Set the files position to current position + pos. See seekSet().
[in] | offset | The new position in bytes from the current position. |
|
inlineinherited |
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. |
|
inherited |
Sets a file's position.
[in] | pos | The new position in bytes from the beginning of the file. |
|
inlineinherited |
|
inherited |
The sync() call causes all modified data and directory fields to be written to the storage device.
|
inherited |
Set a file's timestamps in its directory entry.
[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.
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 |
|
inherited |
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.
|
inlineinherited |
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. |
|
inlineinherited |
Write a string to a file. Used by the Arduino Print class.
[in] | str | Pointer to the string. Use getWriteError to check for errors. |
|
inlineinherited |
Write data to an open file.
[in] | buffer | Pointer to the location of the data to be written. |
[in] | size | Number of bytes to write. |
|
inherited |
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. |
|
inlineinherited |
Write a byte to a file. Required by the Arduino Print class.
[in] | b | the byte to be written. Use getWriteError to check for errors. |