Maestro Audio Framework v 1.7
NXP Semiconductors
Loading...
Searching...
No Matches
file_utils.c File Reference

This file provides file manipulation functions. More...

#include "file_utils.h"
#include <stdbool.h>
#include "fsl_debug_console.h"

Data Structures

struct  File_Fs_Rec
 File descriptor structure. More...
 

Functions

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_Recget_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
 

Variables

static File_Fs_Rec file_fh_table [FILE_FS_TABLE_SIZE]
 File descriptor table.
 

Function Documentation

◆ alloc_fd()

static int32_t alloc_fd ( int32_t fs_type)
static
Parameters
fs_typeFile system type
Returns
int32_t
Return values
fdFile descriptor on success
-1Failure

◆ free_fd()

static int32_t free_fd ( int32_t idx)
static
Parameters
idxFile descriptor ID
Returns
int32_t
Return values
0Success
-1Failure

◆ get_fd()

static File_Fs_Rec * get_fd ( int32_t idx)
static
Parameters
idxFile descriptor ID
Returns
File_Fs_Rec*

◆ file_open()

int32_t file_open ( const char * pathname,
uint32_t mode )

Function to get handle of open device

Parameters
pathnameFile path
modefile mode
Returns
file descriptor

◆ file_close()

int32_t file_close ( int32_t fd)

Function to close file

Parameters
fdFile descriptor
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
fdFile descriptor
buffbuffer pointer
btrbytes 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
fdFile descriptor
buffbuffer pointer
cntbytes 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
fdFile descriptor
offsetfrom 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
fdFile handle
Returns
size of file in bytes