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.
|
#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...
|
|
#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: msg_t (*close)(
void *instance); \
msg_t (*geterror)(
void *instance); \
msg_t (*getsize)(
void *instance); \
msg_t (*getposition)(
void *instance); \
#define _base_sequential_stream_methods
BaseSequentialStream specific methods.
uint32_t fileoffset_t
File offset type.
int32_t msg_t
Type of a message.
FileStream specific methods.
Definition at line 66 of file hal_files.h.
#define fileStreamWrite |
( |
|
ip, |
|
|
|
bp, |
|
|
|
n |
|
) |
| streamWrite(ip, bp, n) |
File stream write.
The function writes data from a buffer to a file stream.
- Parameters
-
[in] | ip | pointer to a FileStream or derived class |
[in] | bp | pointer to the data buffer |
[in] | n | the 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_ERROR | operation 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, |
|
|
|
n |
|
) |
| streamRead(ip, bp, n) |
File stream read.
The function reads data from a file stream into a buffer.
- Parameters
-
[in] | ip | pointer to a FileStream or derived class |
[out] | bp | pointer to the data buffer |
[in] | n | the 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_ERROR | operation 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, |
|
|
|
b |
|
) |
| 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] | ip | pointer to a FileStream or derived class |
[in] | b | the byte value to be written to the channel |
- Returns
- The operation status.
- Return values
-
FILE_OK | if the operation succeeded. |
FILE_ERROR | operation failed. |
FILE_EOF | if 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.
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
-
- Returns
- A byte value from the queue.
- Return values
-
FILE_ERROR | operation failed. |
FILE_EOF | if 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
-
- Returns
- The operation status.
- Return values
-
FILE_OK | no error. |
FILE_ERROR | operation 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
-
- 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
-
- Returns
- The file size.
- Return values
-
FILE_ERROR | operation 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
-
- Returns
- The current position inside the file.
- Return values
-
FILE_ERROR | operation 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] | ip | pointer to a FileStream or derived class |
[in] | offset | new absolute position |
- Returns
- The operation status.
- Return values
-
FILE_OK | no error. |
FILE_ERROR | operation 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.