This file provides file manipulation functions.
More...
#include "file_utils.h"
#include <stdbool.h>
#include "fsl_debug_console.h"
|
static int32_t | alloc_fd (int32_t fs_type) |
| Allocate file descriptor.
|
|
static int32_t | free_fd (int32_t idx) |
| Free file descriptor.
|
|
static File_Fs_Rec * | get_fd (int32_t idx) |
| Get the file descriptor object.
|
|
int32_t | file_open (const char *pathname, uint32_t mode) |
| file_open
|
|
int32_t | file_close (int32_t fd) |
| file_close
|
|
int32_t | file_read (int32_t fd, void *buff, size_t btr) |
| file_read
|
|
int32_t | file_write (int32_t fd, void *buff, size_t cnt) |
| file_write
|
|
int32_t | file_seek (int32_t fd, size_t offset) |
| file_seek
|
|
int32_t | file_getsize (int32_t fd) |
| file_getsize
|
|
◆ alloc_fd()
static int32_t alloc_fd |
( |
int32_t | fs_type | ) |
|
|
static |
- Parameters
-
- Returns
- int32_t
- Return values
-
fd | File descriptor on success |
-1 | Failure |
◆ free_fd()
static int32_t free_fd |
( |
int32_t | idx | ) |
|
|
static |
- Parameters
-
- Returns
- int32_t
- Return values
-
◆ get_fd()
- Parameters
-
- Returns
- File_Fs_Rec*
◆ file_open()
int32_t file_open |
( |
const char * | pathname, |
|
|
uint32_t | mode ) |
Function to get handle of open device
- Parameters
-
pathname | File path |
mode | file mode |
- Returns
- file descriptor
◆ file_close()
int32_t file_close |
( |
int32_t | fd | ) |
|
Function to close file
- Parameters
-
- Returns
- error code of operation
◆ file_read()
int32_t file_read |
( |
int32_t | fd, |
|
|
void * | buff, |
|
|
size_t | btr ) |
Function to read data from file given by handle
- Parameters
-
fd | File descriptor |
buff | buffer pointer |
btr | bytes to be read |
- Returns
- bytes read
◆ file_write()
int32_t file_write |
( |
int32_t | fd, |
|
|
void * | buff, |
|
|
size_t | cnt ) |
Function to write data to file given by handle
- Parameters
-
fd | File descriptor |
buff | buffer pointer |
cnt | bytes to be written |
- Returns
- bytes writen
◆ file_seek()
int32_t file_seek |
( |
int32_t | fd, |
|
|
size_t | offset ) |
Function to seek in given by handle
- Parameters
-
fd | File descriptor |
offset | from start of the file |
- Returns
- error code of operation
◆ file_getsize()
int32_t file_getsize |
( |
int32_t | fd | ) |
|
Function to get the device file size.
- Parameters
-
- Returns
- size of file in bytes