openMSX
FileBase.hh
Go to the documentation of this file.
1 #ifndef FILEBASE_HH
2 #define FILEBASE_HH
3 
4 #include "MemBuffer.hh"
5 #include "span.hh"
6 #include <cstdint>
7 #include <string>
8 
9 namespace openmsx {
10 
11 class FileBase
12 {
13 public:
14  virtual ~FileBase() = default;
15 
16  virtual void read(void* buffer, size_t num) = 0;
17  virtual void write(const void* buffer, size_t num) = 0;
18 
19  // If you override mmap(), make sure to call munmap() in
20  // your destructor.
21  virtual span<uint8_t> mmap();
22  virtual void munmap();
23 
24  virtual size_t getSize() = 0;
25  virtual void seek(size_t pos) = 0;
26  virtual size_t getPos() = 0;
27  virtual void truncate(size_t size);
28  virtual void flush() = 0;
29 
30  virtual std::string getURL() const = 0;
31  virtual std::string getLocalReference();
32  virtual std::string getOriginalName();
33  virtual bool isReadOnly() const = 0;
34  virtual time_t getModificationDate() = 0;
35 
36 private:
37  MemBuffer<uint8_t> mmapBuf;
38 };
39 
40 } // namespace openmsx
41 
42 #endif
virtual std::string getLocalReference()
Definition: FileBase.cc:51
virtual std::string getURL() const =0
Definition: span.hh:34
virtual std::string getOriginalName()
Definition: FileBase.cc:58
virtual ~FileBase()=default
size_t size(std::string_view utf8)
virtual void read(void *buffer, size_t num)=0
virtual void write(const void *buffer, size_t num)=0
virtual void munmap()
Definition: FileBase.cc:26
virtual size_t getSize()=0
virtual bool isReadOnly() const =0
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
virtual span< uint8_t > mmap()
Definition: FileBase.cc:10
virtual void truncate(size_t size)
Definition: FileBase.cc:31
virtual time_t getModificationDate()=0
virtual size_t getPos()=0
virtual void seek(size_t pos)=0
virtual void flush()=0