summaryrefslogtreecommitdiffhomepage
path: root/ArchiveEx/Archive.h
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-08-07 21:45:05 +0200
committerAki <please@ignore.pl>2022-08-07 21:49:13 +0200
commit9ae3b193c461b168336d1d9e272aa834705633d7 (patch)
treecf4dde4eeba653763ab3180e4d581f359899370d /ArchiveEx/Archive.h
parent59af3b9729cb325fa65698f534bb87e77401c6a6 (diff)
downloadstarshatter-9ae3b193c461b168336d1d9e272aa834705633d7.zip
starshatter-9ae3b193c461b168336d1d9e272aa834705633d7.tar.gz
starshatter-9ae3b193c461b168336d1d9e272aa834705633d7.tar.bz2
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.
Diffstat (limited to 'ArchiveEx/Archive.h')
-rw-r--r--ArchiveEx/Archive.h51
1 files changed, 51 insertions, 0 deletions
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 <cstddef>
+#include <cstdint>
+#include <vector>
+
+
+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<Entry> entries;
+};
+
+
+} // namespace Archive