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