File I/O Support for Embedded Systems
2-18
efs_fread()
Read from file
efs_fseek()
Set file position
efs_ftell()
Get file position
efs_fwrite()
Write to file
efs_rewind()
Reset file position to start of file
2.6.3
EFS Custom API Functions
Create (declare) a RAM Based File
efs_createfile
Syntax
void efs_createfile( char *name, INT32 length, UINT8 *pData );
Parameter(s)
name
Filename (max length of EFS_FILENAME_MAX)
length
Length of file datap
Data
Pointer to file data
Return Value
nothing
Description
This function creates an internal record of the RAM based file with the indi-
cated filename, file length, and data pointer. The file data is not copied, so the
buffer must be statically allocated. The filename is copied, so it does not need
to be static.
A static buffer based system is more efficient for embedded systems since the
data must already be present in RAM or ROM. However, the efs_createfile()
function could easily be altered to use allocated buffers which are later freed
when efs_destroyfile() is called. These create and destroy functions are only
called by the sample application code, and thus the system programmer is free
to alter the operation of these functions – so long as they create “files” that are
compatible with the rest of this API.
Destroy (remove declaration from a) RAM Based File
efs_destroyfile
Syntax
void efs_destroyfile( char *name );
Parameter(s)
name
Filename (max length of EFS_FILENAME_MAX)
Return Value
nothing
Description
This function deletes the internal file record associating the filename with the
static data pointer as originally passed to efs_createfile().