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

This file provides file manipulation functions. More...

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

Macros

#define FILE_ENABLE_FATFS
 FatFS enabled.
 
#define FILE_UTILS_NONE   0
 No file utils wrapper used.
 
#define FILE_UTILS_FATFS   1
 FatFS file utils wrapper used.
 
#define FILE_UTILS_SEMI   2
 Semihosting file utils wrapper used.
 
#define FILE_UTILS_FS_SEL   FILE_UTILS_FATFS
 Selection of file system.
 
#define FILE_FS_TABLE_SIZE   1u
 Maximal number of open files.
 
#define FILE_RDONLY   0x01u
 File access mode read only.
 
#define FILE_WRONLY   0x02u
 File access mode write only.
 
#define FILE_RDWR   0x04u
 File access mode read write.
 
#define FILE_APPEND   0x08u
 File access mode append.
 
#define FILE_CREAT   0x10u
 File access mode create.
 
#define FILE_TRUNC   0x20u
 File access mode create and truncates it to 0.
 

Functions

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
 
bool file_exists (const char *filename)
 file_exists
 
bool dir_exists (const char *dirname)
 dir_exists
 

Function Documentation

◆ 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

◆ file_exists()

bool file_exists ( const char * filename)

Returns true if the given file exists on disk and false if not

Parameters
filenameName and path of the file to test for existence
Returns
true or false

◆ dir_exists()

bool dir_exists ( const char * dirname)

Returns true if the given directory exists on disk and false if not

Parameters
dirnameName and path of the directory to test for existence
Returns
true or false