ChibiOS/HAL  6.1.0
Abstract Files
Collaboration diagram for Abstract Files:

Detailed Description

This module define an abstract interface for generic data files by extending the BaseSequentialStream interface. Note that no code is present, data files are just abstract interface-like structures, you should look at the systems as to a set of abstract C++ classes (even if written in C). This system has the advantage to make the access to streams independent from the implementation logic.
The data files interface can be used as base class for high level object types such as an API for a File System implementation.

Macros

#define _file_stream_methods
 FileStream specific methods. More...
 
#define _file_stream_data   _base_sequential_stream_data
 FileStream specific data. More...
 

Files return codes

#define FILE_OK   STM_OK
 No error return code. More...
 
#define FILE_ERROR   STM_TIMEOUT
 Error code from the file stream methods. More...
 
#define FILE_EOF   STM_RESET
 End-of-file condition for file get/put methods. More...
 

Macro Functions (FileStream)

#define fileStreamWrite(ip, bp, n)   streamWrite(ip, bp, n)
 File stream write. More...
 
#define fileStreamRead(ip, bp, n)   streamRead(ip, bp, n)
 File stream read. More...
 
#define fileStreamPut(ip, b)   streamPut(ip, b)
 File stream blocking byte write. More...
 
#define fileStreamGet(ip)   streamGet(ip)
 File stream blocking byte read. More...
 
#define fileStreamClose(ip)   ((ip)->vmt->close(ip))
 File Stream close. More...
 
#define fileStreamGetError(ip)   ((ip)->vmt->geterror(ip))
 Returns an implementation dependent error code. More...
 
#define fileStreamGetSize(ip)   ((ip)->vmt->getsize(ip))
 Returns the current file size. More...
 
#define fileStreamGetPosition(ip)   ((ip)->vmt->getposition(ip))
 Returns the current file pointer position. More...
 
#define fileStreamSeek(ip, offset)   ((ip)->vmt->lseek(ip, offset))
 Moves the file current pointer to an absolute position. More...
 

Typedefs

typedef uint32_t fileoffset_t
 File offset type. More...
 

Data Structures

struct  FileStreamVMT
 FileStream virtual methods table. More...
 
struct  FileStream
 Base file stream class. More...
 

Macro Definition Documentation

#define FILE_OK   STM_OK

No error return code.

Definition at line 45 of file hal_files.h.

#define FILE_ERROR   STM_TIMEOUT

Error code from the file stream methods.

Definition at line 50 of file hal_files.h.

#define FILE_EOF   STM_RESET

End-of-file condition for file get/put methods.

Definition at line 55 of file hal_files.h.

#define _file_stream_methods
Value:
/* File close method.*/ \
msg_t (*close)(void *instance); \
/* Get last error code method.*/ \
msg_t (*geterror)(void *instance); \
/* File get size method.*/ \
msg_t (*getsize)(void *instance); \
/* File get current position method.*/ \
msg_t (*getposition)(void *instance); \
/* File seek method.*/ \
msg_t (*lseek)(void *instance, fileoffset_t offset);
#define _base_sequential_stream_methods
BaseSequentialStream specific methods.
Definition: hal_streams.h:50
uint32_t fileoffset_t
File offset type.
Definition: hal_files.h:61
int32_t msg_t
Type of a message.
Definition: osal.h:160

FileStream specific methods.

Definition at line 66 of file hal_files.h.

#define _file_stream_data   _base_sequential_stream_data

FileStream specific data.

Note
It is empty because FileStream is only an interface without implementation.

Definition at line 84 of file hal_files.h.

#define fileStreamWrite (   ip,
  bp,
 
)    streamWrite(ip, bp, n)

File stream write.

The function writes data from a buffer to a file stream.

Parameters
[in]ippointer to a FileStream or derived class
[in]bppointer to the data buffer
[in]nthe maximum amount of data to be transferred
Returns
The number of bytes transferred. The return value can be less than the specified number of bytes if an end-of-file condition has been met.
Return values
FILE_ERRORoperation failed.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 126 of file hal_files.h.

#define fileStreamRead (   ip,
  bp,
 
)    streamRead(ip, bp, n)

File stream read.

The function reads data from a file stream into a buffer.

Parameters
[in]ippointer to a FileStream or derived class
[out]bppointer to the data buffer
[in]nthe maximum amount of data to be transferred
Returns
The number of bytes transferred. The return value can be less than the specified number of bytes if an end-of-file condition has been met.
Return values
FILE_ERRORoperation failed.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 142 of file hal_files.h.

#define fileStreamPut (   ip,
 
)    streamPut(ip, b)

File stream blocking byte write.

This function writes a byte value to a channel. If the channel is not ready to accept data then the calling thread is suspended.

Parameters
[in]ippointer to a FileStream or derived class
[in]bthe byte value to be written to the channel
Returns
The operation status.
Return values
FILE_OKif the operation succeeded.
FILE_ERRORoperation failed.
FILE_EOFif an end-of-file condition has been met.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 159 of file hal_files.h.

#define fileStreamGet (   ip)    streamGet(ip)

File stream blocking byte read.

This function reads a byte value from a channel. If the data is not available then the calling thread is suspended.

Parameters
[in]ippointer to a FileStream or derived class
Returns
A byte value from the queue.
Return values
FILE_ERRORoperation failed.
FILE_EOFif an end-of-file condition has been met.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 174 of file hal_files.h.

#define fileStreamClose (   ip)    ((ip)->vmt->close(ip))

File Stream close.

The function closes a file stream.

Parameters
[in]ippointer to a FileStream or derived class
Returns
The operation status.
Return values
FILE_OKno error.
FILE_ERRORoperation failed.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 187 of file hal_files.h.

#define fileStreamGetError (   ip)    ((ip)->vmt->geterror(ip))

Returns an implementation dependent error code.

Precondition
The previously called function must have returned FILE_ERROR.
Parameters
[in]ippointer to a FileStream or derived class
Returns
Implementation dependent error code.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 198 of file hal_files.h.

#define fileStreamGetSize (   ip)    ((ip)->vmt->getsize(ip))

Returns the current file size.

Parameters
[in]ippointer to a FileStream or derived class
Returns
The file size.
Return values
FILE_ERRORoperation failed.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 209 of file hal_files.h.

#define fileStreamGetPosition (   ip)    ((ip)->vmt->getposition(ip))

Returns the current file pointer position.

Parameters
[in]ippointer to a FileStream or derived class
Returns
The current position inside the file.
Return values
FILE_ERRORoperation failed.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 220 of file hal_files.h.

#define fileStreamSeek (   ip,
  offset 
)    ((ip)->vmt->lseek(ip, offset))

Moves the file current pointer to an absolute position.

Parameters
[in]ippointer to a FileStream or derived class
[in]offsetnew absolute position
Returns
The operation status.
Return values
FILE_OKno error.
FILE_ERRORoperation failed.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 233 of file hal_files.h.

Typedef Documentation

typedef uint32_t fileoffset_t

File offset type.

Definition at line 61 of file hal_files.h.