Replacing vfs memory mapping with base memory mapping.

Progress on #294.
This commit is contained in:
Ben Vanik
2015-06-27 18:02:20 -07:00
parent 23f91b58f3
commit 1ac19f1b08
10 changed files with 57 additions and 90 deletions

View File

@@ -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_;