Replacing vfs memory mapping with base memory mapping.
Progress on #294.
This commit is contained in:
@@ -22,21 +22,26 @@ class MappedMemory {
|
||||
kReadWrite,
|
||||
};
|
||||
|
||||
virtual ~MappedMemory() = default;
|
||||
|
||||
static std::unique_ptr<MappedMemory> Open(const std::wstring& path, Mode mode,
|
||||
size_t offset = 0,
|
||||
size_t length = 0);
|
||||
|
||||
MappedMemory(const std::wstring& path, Mode mode)
|
||||
: path_(path), mode_(mode), data_(nullptr), size_(0) {}
|
||||
MappedMemory(const std::wstring& path, Mode mode, void* data, size_t size)
|
||||
: path_(path), mode_(mode), data_(data), size_(size) {}
|
||||
virtual ~MappedMemory() = default;
|
||||
|
||||
std::unique_ptr<MappedMemory> Slice(Mode mode, size_t offset, size_t length) {
|
||||
return std::make_unique<MappedMemory>(path_, mode, data() + offset, length);
|
||||
}
|
||||
|
||||
uint8_t* data() const { return reinterpret_cast<uint8_t*>(data_); }
|
||||
size_t size() const { return size_; }
|
||||
|
||||
virtual void Flush() = 0;
|
||||
virtual void Flush() {}
|
||||
|
||||
protected:
|
||||
MappedMemory(const std::wstring& path, Mode mode)
|
||||
: path_(path), mode_(mode), data_(nullptr), size_(0) {}
|
||||
|
||||
std::wstring path_;
|
||||
Mode mode_;
|
||||
void* data_;
|
||||
|
||||
Reference in New Issue
Block a user