From 9ae3b193c461b168336d1d9e272aa834705633d7 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 7 Aug 2022 21:45:05 +0200 Subject: Reimplemented part of archive format This is getting reimplemented rather than refactor mostly in order to make clear which parts are needed for backwards compatiblity (reading-wise) and which are not. The current implementation has quite a number of quirks and potential failure points despite not being large. Understanding them is not worth it. --- ArchiveEx/Archive.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ArchiveEx/Archive.h (limited to 'ArchiveEx/Archive.h') diff --git a/ArchiveEx/Archive.h b/ArchiveEx/Archive.h new file mode 100644 index 0000000..cc06dc4 --- /dev/null +++ b/ArchiveEx/Archive.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include +#include + + +namespace Archive +{ + + +static constexpr std::uint32_t VERSION {0x0010}; +static constexpr std::size_t BLOCK_SIZE {1024}; +static constexpr std::size_t NAMELEN {64}; + + +struct Header +{ + std::uint32_t version; + std::uint32_t total_entries; + struct { + std::uint32_t total_blocks; + std::uint32_t compressed_size; + std::uint32_t offset; + } directory; +}; + + +struct Entry +{ + char name[NAMELEN]; + std::uint32_t original_size; + std::uint32_t compressed_size; + std::uint32_t offset; +}; + + +class Archive +{ +public: + explicit Archive(const char* path); + void PrintNamesOfEntries() const; + std::size_t DirectoryBlocks() const; +private: + const char* path; + Header header; + std::vector entries; +}; + + +} // namespace Archive -- cgit v1.1