Generic file abstraction.
| virtual unsigned long |
Reads a chunk of data at the current position. | |||
| virtual unsigned long |
Writes a chunk of data at the current position. | |||
| virtual void |
Changes current file position. | |||
| virtual long long |
Returns current offset from the beginning of the file. | |||
| virtual void |
Flushes the file, forcing any buffered bytes to be written out. | |||
| void |
Writes an exact number of bytes at the current position. | |||
| int |
Reads an integer at the current file position. | |||
| int |
Reads a doble at the current file position. | |||
| unsigned long |
FIXME Document this |
Reads a chunk of data at the current position.
If more that zero bytes was requested, then at least one byte is guaranteed to be read.
This method should be expected to throw an IOException.
Returns the total number of bytes read into the buffer, or 0 if there is no more data because the end of the file has been reached. Also returns 0 if zero bytes was requested to be read.
virtual unsigned long read (char *buf, unsigned long len) = 0
| buf : | the buffer into which the data is read. |
| len : | the maximum number of bytes to read. |
Writes a chunk of data at the current position.
This method should be expected to throw an IOException.
virtual unsigned long write (const char *buf, unsigned long len) = 0
| len : | the number of bytes to write. |
Changes current file position.
Positioning beyond the end or before the beginning of the file is not allowed.
This method should be expected to throw an IOException.
virtual void seek (long long offset, SeekOrigin origin) = 0
| offset : | an offset to seek by. |
| origin : | -1 - seek from the beginning of the file. 0 - seek from the current position. 1 - seek from the end of the file (the offset should be negative in this case). |
Returns current offset from the beginning of the file.
virtual long long tell () = 0
Flushes the file, forcing any buffered bytes to be written out.
The flush method is expected to write out all pending data and to flush the underlying transport/storage facility, so that all chained File objects get flushed, when the topmost File gets flushed.
This method should be expected to throw an IOException.
virtual void flush () = 0
Writes an exact number of bytes at the current position.
This method operates by calling write method in a loop until the requested portion of data gets fully written to the file.
fullWrite does not support asynchronous files (AsyncFile interface) in asynchoronous mode. The behavior is undefined in this case.
This method should be expected to throw an IOException. More precisely, an IOException will be thrown if either the underlying File object's write method throws an IOException, or if it returns 0 (e.g., if it's an AsyncFile in asynchronous mode, and the file is not ready for writing).
void fullWrite (const char *buf, unsigned long len)
Reads an integer at the current file position.
After execution of this method the file position is set just after an integer read. If there was no valid integer, the position is not altered.
This method should be expected to throw an IOException.
Returns 0 on success.
Returns -1, if there is no valid integer at the current position.
int readInt (int *result)
| result : | a placeholder for the result, may be NULL. |
Reads a doble at the current file position.
After execution of this method the file position is set just after a double read. If there was no valid double, the position is not altered.
This method should be expected to throw an IOException.
Returns 0 on success.
Returns -1, if there is no valid double at the current position.
int readDouble (double *result)
| result : | a placeholder for the result, may be NULL. |
FIXME Document this
unsigned long readLine (char *buf, unsigned long len)