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  unsigned useCount = 0;
20  };
21 
22  void read(void* buffer, size_t num) final;
23  void write(const void* buffer, size_t num) final;
24  [[nodiscard]] span<const uint8_t> mmap() final;
25  void munmap() final;
26  [[nodiscard]] size_t getSize() final;
27  void seek(size_t pos) final;
28  [[nodiscard]] size_t getPos() final;
29  void truncate(size_t size) final;
30  void flush() final;
31  [[nodiscard]] const std::string& getURL() const final;
32  [[nodiscard]] std::string_view getOriginalName() final;
33  [[nodiscard]] bool isReadOnly() const final;
34  [[nodiscard]] time_t getModificationDate() final;
35 
36 protected:
37  explicit CompressedFileAdapter(std::unique_ptr<FileBase> file);
38  ~CompressedFileAdapter() override;
39  virtual void decompress(FileBase& file, Decompressed& decompressed) = 0;
40 
41 private:
42  void decompress();
43 
44 private:
45  std::unique_ptr<FileBase> file;
46  const Decompressed* decompressed = nullptr;
47  size_t pos = 0;
48 };
49 
50 } // namespace openmsx
51 
52 #endif
std::string_view getOriginalName() final
void write(const void *buffer, size_t num) final
span< const uint8_t > mmap() final
const std::string & getURL() const final
void read(void *buffer, size_t num) final
This file implemented 3 utility functions:
Definition: Autofire.cc:5
size_t size(std::string_view utf8)