A random access resource that is simply a local file.
More...
#include <file/nresources.h>
|
static std::ios::openmode | sysModeRead () |
| Returns the system file mode for opening a binary file for reading. More...
|
|
static std::ios::openmode | sysModeWrite () |
| Returns the system file mode for opening a binary file for writing. More...
|
|
A random access resource that is simply a local file.
- Deprecated:
- The preferred way of representing data is using XML which is accessed using text I/O streams.
- Python:
- Not present.
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.
- Internationalisation:
- This routine makes no assumptions about the character encoding used in the given file name, and simply passes it through unchanged to low-level C/C++ file I/O routines.
- Precondition
- Parameter newFileName is not an empty string.
- Parameters
-
newFileName | the pathname of the file that is this resource. |
regina::NLocalFileResource::~NLocalFileResource |
( |
| ) |
|
|
inlinevirtual |
Destroys this resource reference, closing the corresponding file if necessary.
virtual void regina::NLocalFileResource::close |
( |
| ) |
|
|
virtual |
char regina::NLocalFileResource::getChar |
( |
| ) |
|
|
inlinevirtual |
Reads a character from the current position in the resource and moves on to the next position.
- Precondition
- The resource is currently open in read mode.
- Returns
- the character read.
Implements regina::NRandomAccessResource.
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.
- Returns
- the current state of the resource.
Implements regina::NRandomAccessResource.
virtual long regina::NLocalFileResource::getPosition |
( |
| ) |
|
|
virtual |
Returns the current position in the resource.
- Precondition
- The resource is currently open.
- Returns
- the current positon, as counted in bytes.
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.
- Precondition
- The resource is currently closed.
- Returns
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.
- Precondition
- The resource is currently closed.
- Returns
true
on success, false
on failure.
Implements regina::NRandomAccessResource.
void regina::NLocalFileResource::putChar |
( |
char |
c | ) |
|
|
inlinevirtual |
Writes the given character to the resource at the current position and moves on to the next position.
- Precondition
- The resource is currently open in write mode.
- Parameters
-
Implements regina::NRandomAccessResource.
virtual void regina::NLocalFileResource::setPosition |
( |
long |
pos | ) |
|
|
virtual |
Moves to the given position in the resource.
- Precondition
- The resource is currently open.
- Parameters
-
pos | the position to which to move, as counted in bytes. |
Implements regina::NRandomAccessResource.
std::ios::openmode regina::NLocalFileResource::sysModeRead |
( |
| ) |
|
|
inlinestatic |
Returns the system file mode for opening a binary file for reading.
- Returns
- the system file mode for reading.
std::ios::openmode regina::NLocalFileResource::sysModeWrite |
( |
| ) |
|
|
inlinestatic |
Returns the system file mode for opening a binary file for writing.
- Returns
- the system file mode for writing.
The documentation for this class was generated from the following file: