|
| | MemMapper (const std::filesystem::directory_entry &file) |
| | Constructs a MemMapper from a file path. More...
|
| |
|
| MemMapper (const MemMapper &)=delete |
| |
|
| MemMapper (MemMapper &&rhs) noexcept |
| |
|
MemMapper & | operator= (MemMapper &&rhs) noexcept |
| |
| size_t | Size () const noexcept override |
| | Obtains the size of the file. More...
|
| |
| IMemMapper & | Resize (size_t size) override |
| | Resizes the file; semantics are always the same as ftruncate() More...
|
| |
| const uint8_t * | Get () const noexcept override |
| | Obtains a const pointer to the memory-mapped file. More...
|
| |
| uint8_t * | Get () noexcept override |
| | Obtains a pointer to the memory-mapped file. More...
|
| |
◆ MemMapper()
| AssetMap::MemMapper::MemMapper |
( |
const std::filesystem::directory_entry & |
file | ) |
|
|
explicit |
Constructs a MemMapper from a file path.
- Precondition
- If creating a file, the directory hierarchy must exist, it will not create it for you.
- Postcondition
- If the file exists and has a length > 0, it will be opened and mapped. Otherwise, it will be created/opened, but not mapped until a call to Resize() occurs. Even if mapped, the data is never writable after construction.
- Parameters
-
| file | A valid path to an existing file, or location to create one. |
◆ Get() [1/2]
| const uint8_t* AssetMap::MemMapper::Get |
( |
| ) |
const |
|
overridevirtualnoexcept |
Obtains a const pointer to the memory-mapped file.
- Postcondition
- If the instance was constructed from an empty or non-existent file, de-referencing the returned pointer causes undefined behaviour. Debug builds have an assert guard.
- Returns
- the beginning of the memory-mapped data..
Implements AssetMap::IMemMapper.
◆ Get() [2/2]
| uint8_t* AssetMap::MemMapper::Get |
( |
| ) |
|
|
overridevirtualnoexcept |
Obtains a pointer to the memory-mapped file.
- Postcondition
- If the instance was constructed from an empty or non-existent file, de-referencing the returned pointer causes undefined behaviour. Debug builds have an assert guard.
- Returns
- the beginning of the memory-mapped data.
Implements AssetMap::IMemMapper.
◆ Resize()
| IMemMapper& AssetMap::MemMapper::Resize |
( |
size_t |
size | ) |
|
|
overridevirtual |
Resizes the file; semantics are always the same as ftruncate()
- Postcondition
- All existing pointers and references to the memory-mapped area are invalidated. The data will become writable.
- Parameters
-
| size | The size (in bytes) to resize the file to. |
- Returns
- A reference to *this.
Implements AssetMap::IMemMapper.
◆ Size()
| size_t AssetMap::MemMapper::Size |
( |
| ) |
const |
|
overridevirtualnoexcept |
Obtains the size of the file.
- Returns
- The file size (in bytes) - 0 if empty.
Implements AssetMap::IMemMapper.
The documentation for this class was generated from the following file: