openMSX
MemoryBufferFile.hh
Go to the documentation of this file.
1 #ifndef MEMORYBUFFERFILE_HH
2 #define MEMORYBUFFERFILE_HH
3 
4 #include "FileBase.hh"
5 
6 namespace openmsx {
7 
8 class File;
9 
10 class MemoryBufferFile final : public FileBase
11 {
12 public:
14  : buffer(buffer_) {}
15 
16  void read(void* dst, size_t num) override;
17  void write(const void* src, size_t num) override;
18 
19  size_t getSize() override;
20  void seek(size_t newPos) override;
21  size_t getPos() override;
22  void flush() override;
23 
24  std::string getURL() const override;
25  bool isReadOnly() const override;
26  time_t getModificationDate() override;
27 
28 private:
29  span<const uint8_t> buffer;
30  size_t pos = 0;
31 };
32 
34 
35 } // namespace openmsx
36 
37 #endif
openmsx::MemoryBufferFile::seek
void seek(size_t newPos) override
Definition: MemoryBufferFile.cc:28
FileBase.hh
openmsx::MemoryBufferFile::write
void write(const void *src, size_t num) override
Definition: MemoryBufferFile.cc:18
span< const uint8_t >
openmsx::MemoryBufferFile::getSize
size_t getSize() override
Definition: MemoryBufferFile.cc:23
openmsx::MemoryBufferFile::flush
void flush() override
Definition: MemoryBufferFile.cc:38
openmsx::MemoryBufferFile::getURL
std::string getURL() const override
Definition: MemoryBufferFile.cc:43
openmsx::MemoryBufferFile::getPos
size_t getPos() override
Definition: MemoryBufferFile.cc:33
openmsx::MemoryBufferFile
Definition: MemoryBufferFile.hh:11
openmsx::MemoryBufferFile::MemoryBufferFile
MemoryBufferFile(span< const uint8_t > buffer_)
Definition: MemoryBufferFile.hh:13
openmsx::MemoryBufferFile::getModificationDate
time_t getModificationDate() override
Definition: MemoryBufferFile.cc:53
openmsx::memory_buffer_file
File memory_buffer_file(span< const uint8_t > buffer)
Definition: MemoryBufferFile.cc:59
openmsx::FileBase
Definition: FileBase.hh:12
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::MemoryBufferFile::isReadOnly
bool isReadOnly() const override
Definition: MemoryBufferFile.cc:48
openmsx::MemoryBufferFile::read
void read(void *dst, size_t num) override
Definition: MemoryBufferFile.cc:9