Retarget interface provides routines that can be called by the standard C library retarget interface. More...
Functions | |
int32_t | fs_fopen (const char *path, int32_t mode) |
Open a file. | |
int32_t | fs_fclose (int32_t handle) |
Close a file. | |
int32_t | fs_fwrite (int32_t handle, const void *buf, uint32_t cnt) |
Write to a file. | |
int32_t | fs_fread (int32_t handle, void *buf, uint32_t cnt) |
Read from a file. | |
int32_t | fs_fflush (int32_t handle) |
Flush file buffers. | |
int64_t | fs_fseek (int32_t handle, int64_t offset, int32_t whence) |
Move the file position pointer. | |
int64_t | fs_fsize (int32_t handle) |
Get file size. | |
Retarget interface provides routines that can be called by the standard C library retarget interface.
int32_t fs_fclose | ( | int32_t | handle | ) |
Close a file.
[in] | handle | File handle of an opened file. |
The function fs_fclose closes the file associated with the file descriptor 'handle'.
int32_t fs_fflush | ( | int32_t | handle | ) |
Flush file buffers.
[in] | handle | File handle of an opened file. |
The function fs_fflush flushes internal buffers to the storage media and ensures consistent file system state.
int32_t fs_fopen | ( | const char * | path, |
int32_t | mode | ||
) |
Open a file.
[in] | path | String specifying the pathname of the file to be opened. |
[in] | mode | Integer bitmap specifying the file open mode. |
The function fs_fopen 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.
int32_t fs_fread | ( | int32_t | handle, |
void * | buf, | ||
uint32_t | cnt | ||
) |
Read from a file.
[in] | handle | File handle of an opened file. |
[out] | buf | Pointer to the buffer to store read data. |
[in] | cnt | Number of bytes to read. |
The function fs_fread reads cnt bytes from the file associated with the file descriptor 'handle', into the buffer pointed to by buf. The actual number of bytes read can be less than cnt.
int64_t fs_fseek | ( | int32_t | handle, |
int64_t | offset, | ||
int32_t | whence | ||
) |
Move the file position pointer.
[in] | handle | File handle of an opened file. |
[in] | offset | The number of bytes to move. |
[in] | whence | File position location. |
The function fs_fseek moves the file position pointer as specified with parameters 'offset' and 'whence'. Parameter 'whence' can have the following possible values:
int64_t fs_fsize | ( | int32_t | handle | ) |
Get file size.
[in] | handle | File handle of an opened file. |
The function fs_fsize retrieves the size of an opened file associated with the file descriptor 'handle'.
int32_t fs_fwrite | ( | int32_t | handle, |
const void * | buf, | ||
uint32_t | cnt | ||
) |
Write to a file.
[in] | handle | File handle of an opened file. |
[in] | buf | Pointer to the buffer containing data to write. |
[in] | cnt | Number of bytes to write. |
The function fs_fwrite shall write cnt bytes from the buffer pointed to by buf to the file associated with the open file descriptor 'handle'.