|
ESA JPIP server
0.1
|
This is a wrapper class for the FILE functions that provides all the functionality to handle files safely.
More...
#include <file.h>
Public Types | |
| typedef SHARED_PTR< BaseFile< IO > > | Ptr |
| Safe pointer to this class. More... | |
Public Member Functions | |
| BaseFile () | |
Initialized the internal file pointer to NULL. More... | |
| bool | Open (const char *file_name, const char *access) |
| Opens a file with a specific access mode. More... | |
| bool | Open (const string &file_name, const char *access) |
| Opens a file with a specific access mode. More... | |
| template<class IO2 > | |
| bool | Open (const BaseFile< IO2 > &file, const char *access) |
Opens a file with a specific access mode given an already opened File object. More... | |
| bool | OpenForReading (const char *file_name) |
| bool | OpenForReading (const string &file_name) |
| template<class IO2 > | |
| bool | OpenForReading (const BaseFile< IO2 > &file) |
| bool | OpenForWriting (const char *file_name) |
| bool | OpenForWriting (const string &file_name) |
| template<class IO2 > | |
| bool | OpenForWriting (const BaseFile< IO2 > &file) |
| bool | Seek (int offset, int origin=SEEK_SET) const |
| Changes the current position of the file. More... | |
| void | Close () |
| Closes the file. More... | |
| uint64_t | GetOffset () const |
| Returns the current file position. More... | |
| int | IsEOF () const |
Returns the EOF status (feof) of the file. More... | |
| int | GetDescriptor () const |
| Returns the file descriptor. More... | |
| uint64_t | GetSize () const |
| Return the current size of the file, without modifying the file position. More... | |
| int | ReadByte () const |
| Reads a byte from the file. More... | |
| template<typename T > | |
| bool | Read (T *value, int num_bytes=sizeof(T)) const |
| Reads a value from the file. More... | |
| template<typename T > | |
| bool | ReadReverse (T *value, int num_bytes=sizeof(T)) const |
| Reads a value from the file in reverse order. More... | |
| int | WriteByte (int c) const |
| Writes a byte to the file. More... | |
| template<typename T > | |
| bool | Write (T *value, int num_bytes=sizeof(T)) const |
| Writes a value to the file. More... | |
| template<typename T > | |
| bool | WriteReverse (T *value, int num_bytes=sizeof(T)) const |
| Writes a value to the file in reverse order. More... | |
| bool | IsValid () const |
Returns true if the file pointer is not NULL. More... | |
| operator bool () const | |
Returns true if the file pointer is not NULL. More... | |
| virtual | ~BaseFile () |
| The destructor closes the file. More... | |
Static Public Member Functions | |
| static bool | Exists (const char *file_name) |
Returns true if the given file exists. More... | |
Private Attributes | |
| FILE * | file_ptr |
| File pointer. More... | |
This is a wrapper class for the FILE functions that provides all the functionality to handle files safely.
It is defined as a template in order to allow to use either the locked or the unlocked API, by means of the structs LockedAccess and UnlockedAccess. The unlocked API is not thread-safe, but it provides faster file operations.
| typedef SHARED_PTR< BaseFile<IO> > data::BaseFile< IO >::Ptr |
Safe pointer to this class.
|
inline |
Initialized the internal file pointer to NULL.
|
inlinevirtual |
The destructor closes the file.
|
inline |
Closes the file.
|
inlinestatic |
Returns true if the given file exists.
This is a wrapper of the system funcion stat.
|
inline |
Returns the file descriptor.
|
inline |
Returns the current file position.
|
inline |
Return the current size of the file, without modifying the file position.
|
inline |
Returns the EOF status (feof) of the file.
|
inline |
Returns true if the file pointer is not NULL.
|
inline |
Opens a file with a specific access mode.
| file_name | Path name of the file to open. |
| access | Access mode as a fopen compatible format string. |
true if successful.
|
inline |
Opens a file with a specific access mode.
| file_name | Path name of the file to open. |
| access | Access mode as a fopen compatible format string. |
true if successful.
|
inline |
Opens a file with a specific access mode given an already opened File object.
The descriptor of the opened file is duplicated and re-opened with the access mode given.
| file | Opened file. |
| access | Access mode as a fopen compatible format string. |
true if successful.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns true if the file pointer is not NULL.
|
inline |
Reads a value from the file.
| value | Pointer to the value where to store. |
| num_bytes | Number of bytes to read (by default, the size of the value). |
true if successful.
|
inline |
Reads a byte from the file.
|
inline |
Reads a value from the file in reverse order.
| value | Pointer to the value where to store. |
| num_bytes | Number of bytes to read (by default, the size of the value). |
true if successful.
|
inline |
Changes the current position of the file.
| offset | Offset to add to the current position. |
| origin | Origin to use for the change ( SEEK_SET by default). |
true if successful.
|
inline |
Writes a value to the file.
| value | Pointer to the value. |
| num_bytes | Number of bytes to write (by default, the size of the value). |
true if successful.
|
inline |
Writes a byte to the file.
|
inline |
Writes a value to the file in reverse order.
| value | Pointer to the value. |
| num_bytes | Number of bytes to write (by default, the size of the value). |
true if successful.
|
private |
File pointer.