A random access resource that is simply a local file. More...
#include <nresources.h>
Public Member Functions | |
NLocalFileResource (const char *newFileName) | |
Creates a new resource referring to the given file. | |
virtual | ~NLocalFileResource () |
Destroys this resource reference, closing the corresponding file if necessary. | |
virtual bool | openRead () |
Open the resource in read mode. | |
virtual bool | openWrite () |
Open the resource in write mode. | |
virtual void | close () |
Close the resource. | |
virtual mode | getOpenMode () const |
Returns the current state of the resource. | |
virtual char | getChar () |
Reads a character from the current position in the resource and moves on to the next position. | |
virtual void | putChar (char c) |
Writes the given character to the resource at the current position and moves on to the next position. | |
virtual long | getPosition () |
Returns the current position in the resource. | |
virtual void | setPosition (long pos) |
Moves to the given position in the resource. | |
Static Public Member Functions | |
static std::ios::openmode | sysModeRead () |
Returns the system file mode for opening a binary file for reading. | |
static std::ios::openmode | sysModeWrite () |
Returns the system file mode for opening a binary file for writing. |
A random access resource that is simply a local file.
regina::NLocalFileResource::NLocalFileResource | ( | const char * | newFileName | ) | [inline] |
Creates a new resource referring to the given file.
The file will not be accessed until one of the open...
routines is called.
newFileName | the pathname of the file that is this resource. |
regina::NLocalFileResource::~NLocalFileResource | ( | ) | [inline, virtual] |
Destroys this resource reference, closing the corresponding file if necessary.
virtual void regina::NLocalFileResource::close | ( | ) | [virtual] |
Close the resource.
If the resource is already closed, this routine should do nothing.
Implements regina::NRandomAccessResource.
char regina::NLocalFileResource::getChar | ( | ) | [inline, virtual] |
Reads a character from the current position in the resource and moves on to the next position.
Implements regina::NRandomAccessResource.
NRandomAccessResource::mode regina::NLocalFileResource::getOpenMode | ( | ) | const [inline, virtual] |
Returns the current state of the resource.
If the resource is open, the mode in which it was opened will be returned (either READ
or WRITE
). If the file is closed, 0 (alternatively, CLOSED
) will be returned.
Implements regina::NRandomAccessResource.
virtual long regina::NLocalFileResource::getPosition | ( | ) | [virtual] |
Returns the current position in the resource.
Implements regina::NRandomAccessResource.
virtual bool regina::NLocalFileResource::openRead | ( | ) | [virtual] |
Open the resource in read mode.
This routine should fail if the resource does not exist.
true
on success, false
on failure. Implements regina::NRandomAccessResource.
virtual bool regina::NLocalFileResource::openWrite | ( | ) | [virtual] |
Open the resource in write mode.
If the resource already exists, any existing contents should be deleted.
true
on success, false
on failure. Implements regina::NRandomAccessResource.
void regina::NLocalFileResource::putChar | ( | char | c | ) | [inline, virtual] |
Writes the given character to the resource at the current position and moves on to the next position.
c | the character to write. |
Implements regina::NRandomAccessResource.
virtual void regina::NLocalFileResource::setPosition | ( | long | pos | ) | [virtual] |
Moves to the given position in the resource.
pos | the position to which to move, as counted in bytes. |
Implements regina::NRandomAccessResource.
std::ios::openmode regina::NLocalFileResource::sysModeRead | ( | ) | [inline, static] |
Returns the system file mode for opening a binary file for reading.
std::ios::openmode regina::NLocalFileResource::sysModeWrite | ( | ) | [inline, static] |
Returns the system file mode for opening a binary file for writing.