![]() |
CMSIS-Compiler Support
Version 1.0.0
Standard C Library File, I/O and OS Retargeting
|
Content | |
Definitions | |
Data Structures | |
struct | rt_fs_time_t |
Time and Date Information. More... | |
struct | rt_fs_stat_t |
File Status Information. More... | |
Functions | |
int32_t | rt_fs_open (const char *path, int32_t mode) |
Open a file. More... | |
int32_t | rt_fs_close (int32_t fd) |
Close a file. More... | |
int32_t | rt_fs_write (int32_t fd, const void *buf, uint32_t cnt) |
Write to a file. More... | |
int32_t | rt_fs_read (int32_t fd, void *buf, uint32_t cnt) |
Read from a file. More... | |
int64_t | rt_fs_seek (int32_t fd, int64_t offset, int32_t whence) |
Move the file position pointer. More... | |
int64_t | rt_fs_size (int32_t fd) |
Get file size. More... | |
int32_t | rt_fs_stat (int32_t fd, rt_fs_stat_t *stat) |
Get file status information. More... | |
int32_t | rt_fs_remove (const char *path) |
Remove a file or directory. More... | |
int32_t | rt_fs_rename (const char *oldpath, const char *newpath) |
Rename or move a file or directory. More... | |
struct rt_fs_time_t |
Time and Date Information.
This struct contains time and date information, including seconds, minutes, hours, day of the month, month of the year and year. Values outside of the specified range are treated as invalid. Reserved bits should be ignored.
struct rt_fs_stat_t |
File Status Information.
This struct contains various attributes and metadata about a file or directory in a filesystem, including its attribute bitmap, access time, modification time, change time and filesystem specific block size and block count allocated to store the file.
Data Fields | ||
---|---|---|
rt_fs_time_t | access | Last file data access timestamp. |
uint32_t | attr | File attribute bitmap. |
uint32_t | blkcount | Number of allocated filesystem blocks. |
uint32_t | blksize | The size of filesystem block. |
rt_fs_time_t | change | Last file object change timestamp. |
rt_fs_time_t | modify | Last file data modification timestamp. |
int32_t rt_fs_close | ( | int32_t | fd | ) |
Close a file.
This function closes the file associated with the file descriptor fd.
[in] | fd | file descriptor of an opened file |
int32_t rt_fs_open | ( | const char * | path, |
int32_t | mode | ||
) |
Open a file.
This function opens a file specified by the pathname.
The mode parameter is a bitmap that specifies the file open mode. The following bits are exclusive:
In addition, any combination of the values below can be set:
The file position offset shall be set to the beginning of the file unless append mode is specified.
[in] | path | string specifying the pathname of the file to be opened |
[in] | mode | integer bitmap specifying the file open mode |
int32_t rt_fs_read | ( | int32_t | fd, |
void * | buf, | ||
uint32_t | cnt | ||
) |
Read from a file.
This function reads cnt bytes from the file associated with the file descriptor fd, into the buffer pointed to by buf. The actual number of bytes read can be less than cnt.
[in] | fd | file descriptor of an opened file |
[out] | buf | pointer to the buffer to store read data |
[in] | cnt | number of bytes to read |
int32_t rt_fs_remove | ( | const char * | path | ) |
Remove a file or directory.
If removing a directory, the directory must be empty.
[in] | path | string specifying the pathname |
int32_t rt_fs_rename | ( | const char * | oldpath, |
const char * | newpath | ||
) |
Rename or move a file or directory.
This function changes the name of a file or directory.
If the destination exists, it must match the source in type. If the destination is a directory, the directory must be empty.
[in] | oldpath | string specifying file or directory to be renamed |
[in] | newpath | string specifying the new pathname |
int64_t rt_fs_seek | ( | int32_t | fd, |
int64_t | offset, | ||
int32_t | whence | ||
) |
Move the file position pointer.
This functions moves the file position pointer as specified with parameters offset and whence. Parameter whence can have the following possible values:
[in] | fd | file descriptor of an opened file |
[in] | offset | the number of bytes to move |
[in] | whence | file position location (RT_SEEK_SET, RT_SEEK_CUR, RT_SEEK_END) |
int64_t rt_fs_size | ( | int32_t | fd | ) |
Get file size.
This function retrieves the size of an opened file.
[in] | fd | file descriptor of an opened file |
int32_t rt_fs_stat | ( | int32_t | fd, |
rt_fs_stat_t * | stat | ||
) |
Get file status information.
This function retrieves status information about the file associated with the given file descriptor. The status information is stored in the rt_fs_stat_t struct pointed to by stat. The function shall return with error if fd is not a valid file descriptor or if parameter stat is NULL.
[in] | fd | file descriptor of an opened file |
[out] | stat | pointer to a rt_fs_stat_t object to store the status information in |
int32_t rt_fs_write | ( | int32_t | fd, |
const void * | buf, | ||
uint32_t | cnt | ||
) |
Write to a file.
This function shall write cnt bytes from the buffer pointed to by buf to the file associated with the open file descriptor, fd.
[in] | fd | file descriptor of an opened file |
[in] | buf | pointer to the buffer containing data to write |
[in] | cnt | number of bytes to write |