#pragma once #include #include "Device.hpp" namespace io { class ZipFileDevice : public Device { struct Entry { uint16_t versionMadeBy; uint16_t versionNeeded; uint16_t flags; uint16_t compressionMethod; uint16_t modTime; uint16_t modDate; uint32_t crc32; uint32_t compressedSize; uint32_t uncompressedSize; uint16_t diskNumberStart; uint16_t internalAttributes; uint32_t externalAttributes; uint32_t localHeaderOffset; std::string fileName; size_t blobOffset = 0; bool isDirectory = false; }; public: ZipFileDevice(std::unique_ptr file); std::filesystem::path resolve(std::string_view path) override; std::unique_ptr write(std::string_view path) override; std::unique_ptr read(std::string_view path) override; size_t size(std::string_view path) override; bool exists(std::string_view path) override; bool isdir(std::string_view path) override; bool isfile(std::string_view path) override; bool mkdir(std::string_view path) override; bool mkdirs(std::string_view path) override; bool remove(std::string_view path) override; uint64_t removeAll(std::string_view path) override; std::unique_ptr list(std::string_view path) override; private: std::unique_ptr file; std::unordered_map entries; Entry readEntry(); void findBlob(Entry& entry); }; }