SdFatFile Class

SdFatFile Class

Description
A class of SD FAT File.

Syntax
class SdFatFile

Members

Public Constructors 
SdFatFile::SdFatFileConstructs a SdFatFile object.
SdFatFile::~SdFatFileDestructs a SdFatFile object.
Public Methods 
SdFatFile::writeWrite content (1 byte or bytes) to the file..
SdFatFile::readRead content (1 byte or bytes) from the file..
SdFatFile::peekRead one byte from the file without moving the curser cursor.
SdFatFile::availableCheck if the cursor is at EOF (End-Of-File).
SdFatFile::flushEnsure that any bytes written to the file are saved to the SD card .
SdFatFile::seekChange cursor to a specific position.
SdFatFile::closeClose file.

SdFatFile::write

Description
Write content (1 byte or bytes) to the file.

Syntax
virtual size_t write(uint8_t c);
virtual size_t write(const uint8_t *buf, size_t size);

Parameters
c: The character to be written.
buf: The buffer to store the content to be written.
size: The length of buffer to be written.

Returns
This function returns the number of byte count that has been successfully written to the file.

Example Code
Example: time_lapse_photography
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/Fatfs/examples/time_lapse_photography/time_lapse_photography.ino)

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

SdFatFile::read

Description
Read content (1 byte or bytes) from the file.

Syntax
virtual int read(void);
int read(void *buf, uint16_t nbyte);

Parameters
buf: The buffer to store the content.
nbyte: The buffer size. (Or can be regarded as the desired length to read).

Returns
This function returns a read character or the size of the read buffer.

Example Code
Example: create_folder
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/Fatfs/examples/create_folder/create_folder.ino)

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

SdFatFile::peek

Description
Read one byte from the file without moving the cursor.

Syntax
virtual int peek(void);

Parameters
NA

Returns
The function returns the read character as an integer number.

Example Code
NA

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

SdFatFile::available

Description
Check if the cursor is at EOF.

Syntax
virtual int available(void);

Parameters
NA

Returns
This function returns “0” if the cursor is at EOF, else returns “1”.

Example Code
NA

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

SdFatFile::flush

Description
Ensure that any bytes written to the file are saved to the SD card.” This is an inherited function from class Stream, and it does not affect SD File.

Syntax
void flush(void);

Parameters
NA

Returns
NA

Example Code
NA

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

SdFatFile::seek

Description
Change cursor to a specific position.

Syntax
int seek(uint32_t pos);

Parameters
pos: The desired position.

Returns
This function returns 0 if the cursor is set a specific position successfully otherwise returns a negative value.

Example Code
NA

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

SdFatFile::close

Description
Close file.

Syntax
int close(void);

Parameters
NA

Returns
This function returns 0 if file is closed successfully otherwise it returns a negative value.

Example Code
Example: last_modified_time
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/Fatfs/examples/last_modified_time/last_modified_time.ino)

Example: create_folde

Notes and Warnings
“SdFatFile.h” must be included to use the class function.

Please confirm that QQ communication software is installed
請先確認已安裝QQ通訊軟體