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
8namespace openmsx {
9
11{
12public:
13 struct Decompressed {
15 size_t size;
16 std::string originalName;
17 std::string cachedURL;
19 unsigned useCount = 0;
20 };
21
22 void read(std::span<uint8_t> buffer) final;
23 void write(std::span<const uint8_t> buffer) final;
24 [[nodiscard]] std::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
36protected:
37 explicit CompressedFileAdapter(std::unique_ptr<FileBase> file);
38 ~CompressedFileAdapter() override;
39 virtual void decompress(FileBase& file, Decompressed& decompressed) = 0;
40
41private:
42 void decompress();
43
44private:
45 std::unique_ptr<FileBase> file;
46 const Decompressed* decompressed = nullptr;
47 size_t pos = 0;
48};
49
50} // namespace openmsx
51
52#endif
void read(std::span< uint8_t > buffer) final
std::string_view getOriginalName() final
std::span< const uint8_t > mmap() final
void write(std::span< const uint8_t > buffer) final
const std::string & getURL() const final
This class manages the lifetime of a block of memory.
Definition MemBuffer.hh:29
This file implemented 3 utility functions:
Definition Autofire.cc:9
STL namespace.