wavelength 1.0.0
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
14using Common::Error;
15using Common::Seconds;
16
18class ZipArchive {
19public:
26 static std::expected<ZipArchive, Error> open(std::vector<std::uint8_t> data);
27
33 [[nodiscard]] std::vector<std::string> names() const;
34
41 [[nodiscard]] std::expected<std::vector<std::uint8_t>, Error>
42 extract(const std::string &name) const;
43
51 [[nodiscard]] std::expected<Seconds, Error> modified(const std::string &name) const;
52
53private:
54 struct Member {
55 std::string name;
56 std::uint16_t method = 0;
57 std::uint32_t crc = 0;
58 std::uint32_t compressedSize = 0;
59 std::uint32_t size = 0;
60 std::uint32_t localOffset = 0;
62 };
63
64 [[nodiscard]] std::expected<const Member *, Error> member(const std::string &name) const;
65
66 explicit ZipArchive(std::vector<std::uint8_t> data);
67
68 std::vector<std::uint8_t> data_;
69 std::vector<Member> members_;
70};
71
72} // namespace Tools::BuildImage
Reader of the stored and deflated members of a zip archive in memory.
Definition ziparchive.h:18
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 an Amplitude disc image with the built executable and IOP modules in place.
Definition directoryvolume.h:20
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