SdFatFs Class

SdFatFs Class

Description
A class for SD FAT File system.

Syntax
class SdFatFs

Members

Public Constructors 
SdFatFs::SdFatFsConstructs a SdFatFs object.
SdFatFs::~SdFatFsDestructs a SdFatFs object.
Public Methods 
SdFatFs::beginInitialize SD FAT File System.
SdFatFs::endDeinitialize SD FAT File System.
SdFatFs::*getRootPathGet the root path of the SD FAT File System.
SdFatFs::readDirList items under a specific folder.
SdFatFs::mkdirCreate a new folder.
SdFatFs::rmRemove folder or file.
SdFatFs::isDirCheck if a specific path is a directory.
SdFatFs::isFileCheck if a specific path is a file.
SdFatFs::getLastModTimeGet the last modified time for a file or directory.
SdFatFs::setLastModTimeSet the last modified time for a file or directory.
SdFatFs::statusGet the status of SD card.
SdFatFs::openOpen a file.

SdFatFs::begin

Description
Initialize SD FAT File System.

Syntax
int begin(void);

Parameters
NA

Returns
This function returns 0 if the execution is successful, else returns a negative value.

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
“SdFatFs.h” must be included to use the class function.

SdFatFs::end

Description
De-initialize SD FAT File System.

Syntax
int end(void);

Parameters
NA

Returns
This function returns 0 if the execution is successful, else returns a negative value.

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
“SdFatFs.h” must be included to use the class function.

SdFatFs::*getRootPath

Description
Get the root path of the SD FAT File System. The logical volume character is starting from ‘0’, so the root path would like “0:/”.

Syntax
char *getRootPath(void);

Parameters
NA

Returns
This function returns the root path.

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
“SdFatFs.h” must be included to use the class function.

SdFatFs::readDir

Description
List items under a specific folder. List items under a specific folder and store the result in the buffer that user specified. Each item is separated by ‘\0’.

Syntax
int readDir(char *path, char *result_buf, unsigned int bufsize);

Parameters
path: The absolute directory path to be listed.
result_buf: The buffer to be stored results.
bufsize: The size of result_buf. If results exceed this size, then the results larger than this size would be discarded.

Returns
This function returns “0” if successful, else returns a negative value.

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

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

SdFatFs::mkdir

Description
Create a new folder. The newly created folder shall be an empty folder.

Syntax
int mkdir(char *absolute_path);

Parameters
absolute_path: The absolute directory path to be created.

Returns
This function returns “0” if successful, else returns a negative value.

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
“SdFatFs.h” must be included to use the class function.

SdFatFs::rm

Description
Remove folder or file.

Syntax
int rm(char *absolute_path);

Parameters
absolute_path: The absolute directory or file path to be deleted.

Returns
This function returns “0” if successful, else returns a negative value

Example Code
NA

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

SdFatFs::isDir

Description
Check if a specific path is a directory.

Syntax
unsigned char isDir(char *absolute_path);

Parameters
absolute_path: The absolute path to be queried.

Returns
The function returns “1” if it is a directory, else returns “0”.

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

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

SdFatFs::isFile

Description
Check if a specific path is a file.

Syntax
unsigned char isFile(char *absolute_path);

Parameters
absolute_path: The absolute path to be queried.

Returns
This function returns “1” if it is a directory, else returns “0”.

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

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

SdFatFs::getLastModTime

Description
Get the last modified timestamp for a file or directory.

Syntax
int getLastModTime(char *absolute_path, uint16_t *year, uint16_t *month, uint16_t *date, uint16_t *hour, uint16_t *minute, uint16_t *second);

Parameters
absolute_path: The absolute path to be queried.
year: The value of the year.
month: The value of the month.
date: The value of the date.
hour: The value of an hour.
minute: The value of a minute.
second: field “second” contains no valid information in the current version.

Returns
This function returns “0” if the last modified timestamp is achieved successfully, otherwise 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)

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

SdFatFs::setLastModTime

Description
Set the last modified timestamp for a file or directory. Ameba doesn’t have built-in RTC. So we manually change file/directory last modified time.

Syntax
int setLastModTime(char *absolute_path, uint16_t year, uint16_t month, uint16_t date, uint16_t hour, uint16_t minute, uint16_t second);

Parameters
absolute_path: The absolute path to be queried.
year: The value of the year.
month: The value of the month.
date: The value of the date.
hour: The value of an hour.
minute: The value of a minute.
second: field “second” contains no valid information in the current version.

Returns
This function returns “0” if the last modified timestamp is set successfully, otherwise 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)

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

SdFatFs::status

Description
Return the current status of SD.

Syntax
int status(void);

Parameters
NA

Returns
This function returns “1” if SD card is ready to use, else return “0” if the status is inactivating or abnormal.

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
“SdFatFs.h” must be included to use the class function.

SdFatFs::open

Description
Open a file.

Syntax
SdFatFile open(char *absolute_path);

Parameters
absolute_path: The path to a file.

Returns
This function returns file object which is an instance of SdFatFile.

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
“SdFatFs.h” must be included to use the class function.

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