Functions
Serval_Filesystem.h File Reference

An interface to the platform filesystem. More...

#include <Serval_Types.h>
+ Include dependency graph for Serval_Filesystem.h:
+ This graph shows which files directly or indirectly include this file:

Functions

retcode_t Filesystem_close (FileHandle_T handle)
 
unsigned int Filesystem_getLength (FileHandle_T fh)
 
bool Filesystem_isValidHandle (FileHandle_T handle)
 
retcode_t Filesystem_open (char const *name_ptr, FileHandle_T *handle_ptr)
 
retcode_t Filesystem_read (FileHandle_T fh, char *buffer_ptr, unsigned int count, unsigned int offset, unsigned int *readbytes_ptr)
 

Detailed Description

This interface provides a simple flat read-only filesystem. 'Flat' means there are no directories, there is only a set of files in the root. A file represents data stored on flash or external storage.

The interface provides functions to open, close and read a file. It provides further functions to retrieve the length of a file and to check if a file handler is a valid one.

Function Documentation

retcode_t Filesystem_close ( FileHandle_T  handle)

Function wrapper to close a file. After invoking this function the file is closed and read access is not possible with given file handle.

Parameters
[in]handleHandler to the file needed to be closed. It has to be valid.
Returns
RC_OK if the file has been successfully closed
RC_FILES_BAD_NAME if filename not valid
RC_FILES_ACCESS_ERROR access to file failed
RC_FILES_BAD_DSCR handle is not valid
unsigned int Filesystem_getLength ( FileHandle_T  fh)

This function is called to fetch the size of a file, whose handle is given.

Parameters
[in]fhHandle to the file whose size is required. A valid file handler is required before calling this function. The file must be open.
Returns
Size of the file
See also
Filesystem_open()
bool Filesystem_isValidHandle ( FileHandle_T  handle)

This function is called to check whether a given file handle is valid or not and return the result.

Parameters
[in]handleHandle to the file needed to be checked.
Returns
TRUE if file handler is valid, FALSE if file handler is invalid.
retcode_t Filesystem_open ( char const *  name_ptr,
FileHandle_T handle_ptr 
)

Function wrapper to open a file (read-only). Before invoking this function a directory with a file with the given name should exist. After invoking this function, if successful, the given file handler can be used to read and close the file.

Parameters
[in]name_ptrName of the file to open. A file with the given name has to exist.
[out]handle_ptrHandle to the file. Invalid file handle if the file cannot be opened for any reason, for example if the file does not exist.
Returns
RC_OK if the file handle has been successfully retrieved
RC_FILES_TOO_MANY_OPEN if already too many files are open
RC_FILES_NOT_EXIST if file does not exist
RC_FILES_NO_SYSTEM if no filesystem or filesystem is broken
RC_FILES_BAD_NAME if filename not valid
RC_FILES_ACCESS_ERROR access to file failed
retcode_t Filesystem_read ( FileHandle_T  fh,
char *  buffer_ptr,
unsigned int  count,
unsigned int  offset,
unsigned int *  readbytes_ptr 
)

Function wrapper to read from a file. This function when called reads up to given count bytes from the given file handle fh (starting at the given offset) into the given buffer reference.

Parameters
[in]fhHandler to the file needed to be read. A valid file handler is required before calling this function. The file must be open.
[out]buffer_ptrReference to a buffer where read data will be saved
[in]countNumber of bytes to be read
[in]offsetThe position to start reading from the given file handle
[out]readbytes_ptrNumber of bytes read
Returns
RC_OK if read operation was successful
RC_FILES_ACCESS_ERROR access to file failed
RC_FILES_BAD_DSCR handle is not valid
See also
Filesystem_open()

This documentation file has been automatically generated on Fri Oct 4 2019 03:47:22 by doxygen 1.8.8