Allows to map an entire file into memory for random access.
More...
#include <MemoryMappedFile.h>
|
plResult | Open (plStringView sAbsolutePath, Mode mode) |
| Attempts to open the given file and map it into memory.
|
|
plResult | OpenShared (plStringView sSharedName, plUInt64 uiSize, Mode mode) |
| Attempts to open or create the given shared memory block addressed by szSharedName.
|
|
void | Close () |
| Removes the memory mapping. Outstanding modifications will be written back to disk at this point.
|
|
Mode | GetMode () const |
| Returns the mode with which the file was opened or None, if is currently not in use.
|
|
plUInt64 | GetFileSize () const |
| Returns the size (in bytes) of the memory mapping. Zero if no file is mapped at the moment.
|
|
const void * | GetReadPointer (plUInt64 uiOffset=0, OffsetBase base=OffsetBase::Start) const |
| Returns a pointer for reading the mapped file. Asserts that the memory mapping was done successfully.
|
|
void * | GetWritePointer (plUInt64 uiOffset=0, OffsetBase base=OffsetBase::Start) |
| Returns a pointer for writing the mapped file. Asserts that the memory mapping was successful and the mode was ReadWrite.
|
|
Allows to map an entire file into memory for random access.
◆ Mode
Enumerator |
---|
None | Currently no file is mapped.
|
ReadOnly | File is mapped for read-only access.
|
ReadWrite | File is mapped for read/write access.
|
◆ OffsetBase
The start point for interpreting byte offsets into the memory.
Enumerator |
---|
Start | Byte offsets are relative to the start of the mapped memory.
|
End | Byte offsets are relative to the end of the mapped memory. Increasing positive values go towards the start of the memory.
|
◆ Open()
Attempts to open the given file and map it into memory.
- Parameters
-
szAbsolutePath | must be an absolute path to the file that should be mapped. The file also must exist and have a size larger than zero bytes. |
mode | How to map the file into memory. |
◆ OpenShared()
Attempts to open or create the given shared memory block addressed by szSharedName.
- Parameters
-
szSharedName | The name of the shared memory region. |
uiSize | The size of the memory which should be mapped. |
mode | How to map the file into memory. |
The documentation for this class was generated from the following files: