// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later // A small ZIP reader/writer (zlib) for project bundles (.szgz) and backups, the // archives java.util.zip writes and reads on Android. Whole archives in memory. // Writes deflated entries with sizes and CRC in the local headers (no data // descriptors), so ZipInputStream reads them. Reads through the central directory, // so entries with data descriptors (what ZipOutputStream writes) are fine. No // Zip64, no encryption. #pragma once #include #include #include #include namespace sizzle::io::zip { struct Entry { std::string name; std::vector data; }; /** An archive of [entries], deflated. */ std::vector write(const std::vector &entries); /** * Every file entry of the archive in [bytes] (directories skipped). False, with * [out] cleared, if it isn't a ZIP, is damaged (a CRC mismatch too), uses a * method other than stored/deflate, has more than [maxEntries] entries or more * than [maxTotal] bytes uncompressed (Android's ZipLimits budgets). */ bool read(const uint8_t *bytes, size_t size, std::vector &out, uint64_t maxTotal = 512ull << 20, size_t maxEntries = 20000); /** A name that is safe to extract: relative, no "..", no backslashes or NULs. */ bool safeName(const std::string &name); } // namespace sizzle::io::zip