An abstraction of a memory-mapped file.
More...
#include <MemoryMappedFile.h++>
An abstraction of a memory-mapped file.
- Author
- Mark Lindner
◆ MemoryMappedFile()
Construct a new MemoryMappedFile for the given path.
- Parameters
-
path | The path of the file to be mapped. |
◆ ~MemoryMappedFile()
Destructor.
Unmaps the file.
◆ close()
Unmap and close the file.
◆ getBase() [1/2]
Get a pointer to the base of the mapped memory segment.
◆ getBase() [2/2]
const byte_t* getBase |
( |
| ) |
const |
|
inline |
Get a pointer to the base of the mapped memory segment.
◆ getSize()
uint64_t getSize |
( |
| ) |
const |
|
inline |
Get the size of the memory mapped segment, in bytes.
◆ open()
void open |
( |
uint64_t |
size = 0 , |
|
|
bool |
readOnly = false |
|
) |
| |
Open the file and map it into memory.
Zero-length files cannot be mapped.
- Parameters
-
size | The maximum file size to map; if the file being mapped is larger than this size, the file is truncated to the new size before it is mapped into memory. A value of 0 indicates that the maximum size is the current size of the file. |
readOnly | A flag indicating whether the file should be mapped as read-only or read-write. If mapping read-only, the size parameter is ignored, and taken as 0. |
- Exceptions
-
IOException | If the file to be mapped has a length of 0, or if the file could not be opened or the mapping operation failed. |
◆ sync()
void sync |
( |
bool |
async = false | ) |
|
Synchronize the in-memory state of the file with the file on disk.
- Parameters
-
async | A flag indicating whether the sync operation should occur asynchronously. |
- Exceptions
-
The documentation for this class was generated from the following files: