#include <rex/memory/virtual_memory.h>
|
| enum class | Mode : u8 { kRead
, kReadWrite
} |
|
| | MappedMemory (void *data, size_t size) |
| std::unique_ptr< MappedMemory > | Range (size_t offset, size_t length) const |
| u8 * | GetData () const |
|
size_t | GetSize () const |
| virtual void | Close (u64 truncate_size=0) |
|
virtual void | Flush () |
| virtual bool | Remap (size_t offset, size_t length) |
|
| static std::unique_ptr< MappedMemory > | Open (const std::filesystem::path &path, Mode mode, size_t offset=0, size_t length=0) |
|
|
void * | data_ = nullptr |
|
size_t | size_ = 0 |
|
|
| NonCopyable (const NonCopyable &)=delete |
|
NonCopyable & | operator= (const NonCopyable &)=delete |
A file, or a range of a file, mapped into host memory.
◆ MappedMemory()
| rex::memory::MappedMemory::MappedMemory |
( |
void * | data, |
|
|
size_t | size ) |
|
inline |
Wraps memory the object does not own.
◆ Close()
| virtual void rex::memory::MappedMemory::Close |
( |
u64 | truncate_size = 0 | ) |
|
|
inlinevirtual |
Unmaps the memory and closes the file.
- Parameters
-
| truncate_size | Size to truncate the file to, or 0 to keep its size. |
◆ GetData()
| u8 * rex::memory::MappedMemory::GetData |
( |
| ) |
const |
|
inline |
Returns the start of the mapped memory. It is null once closed.
◆ Open()
| std::unique_ptr< MappedMemory > rex::memory::MappedMemory::Open |
( |
const std::filesystem::path & | path, |
|
|
Mode | mode, |
|
|
size_t | offset = 0, |
|
|
size_t | length = 0 ) |
|
static |
Maps an existing file.
- Parameters
-
| offset | Byte offset of the mapped range in the file. |
| length | Byte count of the range, or 0 to map to the end of the file. |
- Returns
- The mapping, or null on failure.
◆ Range()
| std::unique_ptr< MappedMemory > rex::memory::MappedMemory::Range |
( |
size_t | offset, |
|
|
size_t | length ) const |
|
inline |
Returns a view of part of this mapping, valid while it stays open.
- Parameters
-
| offset | Byte offset of the view in this mapping. |
◆ Remap()
| virtual bool rex::memory::MappedMemory::Remap |
( |
size_t | offset, |
|
|
size_t | length ) |
|
inlinevirtual |
Maps a different range of the file.
- Parameters
-
| offset | Byte offset of the new range in the file. |
| length | Byte count of the new range, or 0 to map to the end of the file. |
- Returns
- True on success. Always false on POSIX.
The documentation for this class was generated from the following file: