ChibiOS/RT
2.5.1
Abstract File Streams
Collaboration diagram for Abstract File Streams:

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.

Data Structures

struct  BaseFileStreamVMT
 BaseFileStream virtual methods table. More...
struct  BaseFileStream
 Base file stream class. More...

Macro Functions (BaseFileStream)

#define chFileStreamClose(ip)   ((ip)->vmt->close(ip))
 Base file Stream close.
#define chFileStreamGetError(ip)   ((ip)->vmt->geterror(ip))
 Returns an implementation dependent error code.
#define chFileStreamGetSize(ip)   ((ip)->vmt->getsize(ip))
 Returns the current file size.
#define chFileStreamGetPosition(ip)   ((ip)->vmt->getposition(ip))
 Returns the current file pointer position.
#define chFileStreamSeek(ip, offset)   ((ip)->vmt->lseek(ip, offset))
 Moves the file current pointer to an absolute position.

Defines

#define FILE_OK   0
 No error return code.
#define FILE_ERROR   0xFFFFFFFFUL
 Error code from the file stream methods.
#define _base_file_stream_methods
 BaseFileStream specific methods.
#define _base_file_stream_data   _base_sequential_stream_data
 BaseFileStream specific data.

Typedefs

typedef uint32_t fileoffset_t
 File offset type.

Define Documentation

#define FILE_OK   0

No error return code.

Definition at line 45 of file chfiles.h.

#define FILE_ERROR   0xFFFFFFFFUL

Error code from the file stream methods.

Definition at line 50 of file chfiles.h.

#define _base_file_stream_methods
Value:
_base_sequential_stream_methods                                           \
  /* File close method.*/                                                   \
  uint32_t (*close)(void *instance);                                        \
  /* Get last error code method.*/                                          \
  int (*geterror)(void *instance);                                          \
  /* File get size method.*/                                                \
  fileoffset_t (*getsize)(void *instance);                                  \
  /* File get current position method.*/                                    \
  fileoffset_t (*getposition)(void *instance);                              \
  /* File seek method.*/                                                    \
  uint32_t (*lseek)(void *instance, fileoffset_t offset);

BaseFileStream specific methods.

Definition at line 60 of file chfiles.h.

#define _base_file_stream_data   _base_sequential_stream_data

BaseFileStream specific data.

Note:
It is empty because BaseFileStream is only an interface without implementation.

Definition at line 78 of file chfiles.h.

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

Base file Stream close.

The function closes a file stream.

Parameters:
[in]ippointer to a BaseFileStream 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 117 of file chfiles.h.

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

Returns an implementation dependent error code.

Parameters:
[in]ippointer to a BaseFileStream 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 127 of file chfiles.h.

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

Returns the current file size.

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

Definition at line 137 of file chfiles.h.

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

Returns the current file pointer position.

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

Definition at line 147 of file chfiles.h.

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

Moves the file current pointer to an absolute position.

Parameters:
[in]ippointer to a BaseFileStream 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 160 of file chfiles.h.


Typedef Documentation

typedef uint32_t fileoffset_t

File offset type.

Definition at line 55 of file chfiles.h.