resonance 1.0.1
Loading...
Searching...
No Matches
ziparchive.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <expected>
5#include <span>
6#include <string>
7#include <vector>
8
9#include "error.h"
10#include "isodate.h"
11
12namespace Tools::BuildImage {
13
15class ZipArchive {
16public:
23 static std::expected<ZipArchive, Error> open(std::vector<std::uint8_t> data);
24
30 [[nodiscard]] std::vector<std::string> names() const;
31
38 [[nodiscard]] std::expected<std::vector<std::uint8_t>, Error>
39 extract(const std::string &name) const;
40
48 [[nodiscard]] std::expected<Seconds, Error> modified(const std::string &name) const;
49
50private:
51 struct Member {
52 std::string name;
53 std::uint16_t method = 0;
54 std::uint32_t crc = 0;
55 std::uint32_t compressedSize = 0;
56 std::uint32_t size = 0;
57 std::uint32_t localOffset = 0;
59 };
60
61 [[nodiscard]] std::expected<const Member *, Error> member(const std::string &name) const;
62
63 explicit ZipArchive(std::vector<std::uint8_t> data);
64
65 std::vector<std::uint8_t> data_;
66 std::vector<Member> members_;
67};
68
69} // namespace Tools::BuildImage
Reader of the stored and deflated members of a zip archive in memory.
Definition ziparchive.h:15
std::vector< std::string > names() const
List the member names in central directory order.
std::expected< std::vector< std::uint8_t >, Error > extract(const std::string &name) const
Extract one member.
std::expected< Seconds, Error > modified(const std::string &name) const
Read the modification time of one member.
static std::expected< ZipArchive, Error > open(std::vector< std::uint8_t > data)
Read the central directory of an archive.
Writer of a FreQuency disc image with the built executable and module in place.
Definition byteorder.h:7
std::chrono::sys_seconds Seconds
A UTC time with a resolution of one second.
Definition isodate.h:20
Failure returned through std::expected.
Definition error.h:17