Generic File for Input/Output. More...
#include <riofile.h>
Public Member Functions | |
RIOFile (void) | |
RIOFile (const RURI &uri) | |
RIOFile (RIOFile &file) | |
RURI | GetRealName (void) const |
virtual void | Open (RIO::ModeType mode) |
void | Open (const RURI &uri, RIO::ModeType mode) |
bool | IsOpen (void) const |
virtual void | Close (void) |
size_t | Read (char *buffer, size_t nb, bool move=true) |
void | Write (const char *buffer, size_t nb) |
virtual void | Seek (off_t pos) |
virtual void | SeekRel (off_t pos) |
virtual void | SeekToEnd (void) |
void | Truncate (off_t newsize) |
bool | End (void) const |
off_t | GetSize (void) const |
off_t | GetPos (void) const |
virtual | ~RIOFile (void) |
Public Member Functions inherited from RFile | |
RFile (void) | |
RFile (const RURI &uri) | |
RFile (const RFile &file) | |
void | Open (const RURI &uri, RIO::ModeType mode) |
int | Compare (const RFile &file) const |
int | Compare (const RFile *file) const |
int | Compare (const RString &uri) const |
const RURI & | GetURI (void) const |
void | SetURI (const RURI &uri) |
const RString | GetFileName (void) const |
virtual | ~RFile (void) |
Protected Attributes | |
bool | CanWrite |
bool | CanRead |
Protected Attributes inherited from RFile | |
RIO::ModeType | Mode |
RURI | URI |
Private Member Functions | |
void | Test (void) |
Private Attributes | |
int | Handle |
off_t | Size |
off_t | Pos |
RURI | File |
char * | Internal |
size_t | InternalToRead |
off_t | RealPos |
off_t | RealInternalPos |
char * | CurByte |
Static Private Attributes | |
static RDownloadFile | Get |
Additional Inherited Members | |
Static Public Member Functions inherited from RFile | |
static RChar | GetDirSeparator (void) |
static void | RemoveFile (const RURI &uri) |
static void | RenameFile (const RURI &olduri, const RURI &newuri) |
static RURI | GetTempFile (void) |
static bool | Exists (const RURI &uri) |
static bool | IsDir (const RURI &uri) |
Detailed Description
Generic File for Input/Output.
The RIOFile class represents a file that can do some input and/or output tasks. To read, the class works with an internal buffer of 10 Kb.
Here is an example:
- Note
- When the file is read, an internal buffer is used to avoid to many accesses to the disk. When something must be written, it is first physically written on the disk and, if the file can also be read, the internal buffer is updated.
Constructor & Destructor Documentation
RIOFile | ( | void | ) |
Default constructor for a file.
|
virtual |
Destruct the file.
Member Function Documentation
|
private |
RURI GetRealName | ( | void | ) | const |
When the URI associated to a RIOFile is not local, it is downloaded and stored in a temporary file (which becomes the real name of the file).
- Returns
- the real name of the file.
|
virtual |
Open the file
- Parameters
-
mode The open mode for the file.
Reimplemented from RFile.
Reimplemented in RXMLParser, RTextFile, RKeyValueFile< K >, RRecFile< C, bOrder >, RBlockFile, RCSVFile, RXMLFile, RBinaryFile, and RHTMLFile.
void Open | ( | const RURI & | uri, |
RIO::ModeType | mode | ||
) |
Open the file
- Parameters
-
uri URI of the file. mode The open mode for the file.
bool IsOpen | ( | void | ) | const |
Verify if the file is opened or not.
- Returns
- true if the file is open.
|
virtual |
Close the file.
Reimplemented from RFile.
Reimplemented in RTextFile, RKeyValueFile< K >, RRecFile< C, bOrder >, RBlockFile, RCSVFile, and RXMLFile.
size_t Read | ( | char * | buffer, |
size_t | nb, | ||
bool | move = true |
||
) |
Read a given number of bytes at the current position of the file.
- Parameters
-
buffer Buffer (must be allocated). nb Number of bytes to read. move The file position is moved (default).
- Returns
- Number of bytes read.
void Write | ( | const char * | buffer, |
size_t | nb | ||
) |
Write the first number of bytes of a buffer in the current position of the file.
- Parameters
-
buffer Buffer. nb Number of bytes to read.
|
virtual |
Go to a specific position of the file.
- Parameters
-
pos Position to reach.
Reimplemented in RKeyValueFile< K >, and RTextFile.
|
virtual |
Move for a given number of bytes from the current position of the file.
- Parameters
-
pos Relative position.
Reimplemented in RTextFile.
|
virtual |
Go to the end of the file.
void Truncate | ( | off_t | newsize | ) |
Truncate the file.
- Parameters
-
newsize New size.
bool End | ( | void | ) | const |
Return true if the file is at the end.
off_t GetSize | ( | void | ) | const |
Return the size of the file.
off_t GetPos | ( | void | ) | const |
Return the current position in the file.
Field Documentation
|
private |
Internal Handle of the file.
|
private |
Size of the file.
|
private |
Current (virtual) position in the file.
|
staticprivate |
Downloader for non-local files.
|
private |
File which is really treated.
|
private |
Internal Buffer.
|
private |
Number of bytes left to read in the internal buffer.
|
private |
Physical (real) position in the file.
|
private |
Physical (real) position of the first byte of the internal buffer.
|
private |
Current byte to read.
|
protected |
It is possible to write in the file.
|
protected |
It is possible to read from the file.