MemoryMappedFile Class Reference
An abstraction of a memory-mapped file.
More...
#include <MemoryMappedFile.h++>
List of all members.
Public Member Functions |
| | MemoryMappedFile (const String &path) |
| | Construct a new MemoryMappedFile for the given path.
|
| | ~MemoryMappedFile () throw () |
| | Destructor.
|
| void | open (uint64_t size=0, bool readOnly=false) throw (IOException) |
| | Open the file and map it into memory.
|
| void | close () throw () |
| | Unmap and close the file.
|
| void | sync (bool async=false) throw (IOException) |
| | Synchronize the in-memory state of the file with the file on disk.
|
| byte_t * | getBase () throw () |
| | Get a pointer to the base of the mapped memory segment.
|
| const byte_t * | getBase () const throw () |
| | Get a pointer to the base of the mapped memory segment.
|
| uint64_t | getSize () const throw () |
| | Get the size of the memory mapped segment, in bytes.
|
Detailed Description
An abstraction of a memory-mapped file.
- Author:
- Mark Lindner
Constructor & Destructor Documentation
Construct a new MemoryMappedFile for the given path.
- Parameters:
-
| path | The path of the file to be mapped. |
Destructor.
Unmaps the file.
Member Function Documentation
Unmap and close the file.
| const byte_t* getBase |
( |
|
) |
const throw () [inline] |
Get a pointer to the base of the mapped memory segment.
| byte_t* getBase |
( |
|
) |
throw () [inline] |
Get a pointer to the base of the mapped memory segment.
| uint64_t getSize |
( |
|
) |
const throw () [inline] |
Get the size of the memory mapped segment, in bytes.
| void open |
( |
uint64_t |
size = 0, |
|
|
bool |
readOnly = false | |
|
) |
| | throw (IOException) |
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. |
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: