openMSX
CompressedFileAdapter.hh
Go to the documentation of this file.
1 #ifndef COMPRESSEDFILEADAPTER_HH
2 #define COMPRESSEDFILEADAPTER_HH
3 
4 #include "FileBase.hh"
5 #include "MemBuffer.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
11 {
12 public:
13  struct Decompressed {
15  size_t size;
16  std::string originalName;
17  std::string cachedURL;
19  };
20 
21  void read(void* buffer, size_t num) final override;
22  void write(const void* buffer, size_t num) final override;
23  span<uint8_t> mmap() final override;
24  void munmap() final override;
25  size_t getSize() final override;
26  void seek(size_t pos) final override;
27  size_t getPos() final override;
28  void truncate(size_t size) final override;
29  void flush() final override;
30  std::string getURL() const final override;
31  std::string getOriginalName() final override;
32  bool isReadOnly() const final override;
33  time_t getModificationDate() final override;
34 
35 protected:
36  explicit CompressedFileAdapter(std::unique_ptr<FileBase> file);
37  ~CompressedFileAdapter() override;
38  virtual void decompress(FileBase& file, Decompressed& decompressed) = 0;
39 
40 private:
41  void decompress();
42 
43  std::unique_ptr<FileBase> file;
44  std::shared_ptr<Decompressed> decompressed;
45  size_t pos;
46 };
47 
48 } // namespace openmsx
49 
50 #endif
span< uint8_t > mmap() final override
std::string getURL() const final override
Definition: span.hh:34
std::string getOriginalName() final override
void read(void *buffer, size_t num) final override
STL namespace.
void write(const void *buffer, size_t num) final override
void seek(size_t pos) final override
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void truncate(size_t size) final override
time_t getModificationDate() final override
bool isReadOnly() const final override