2025-12-03 22:00:29 +11:00
|
|
|
#pragma once
|
2025-12-08 00:39:17 +11:00
|
|
|
#include <Print.h>
|
|
|
|
|
|
2025-12-03 22:00:29 +11:00
|
|
|
#include <string>
|
|
|
|
|
|
2025-12-08 00:39:17 +11:00
|
|
|
#include "miniz.h"
|
|
|
|
|
|
2025-12-03 22:00:29 +11:00
|
|
|
class ZipFile {
|
|
|
|
|
std::string filePath;
|
2025-12-21 04:38:51 +01:00
|
|
|
mutable mz_zip_archive zipArchive = {};
|
2025-12-08 00:39:17 +11:00
|
|
|
bool loadFileStat(const char* filename, mz_zip_archive_file_stat* fileStat) const;
|
|
|
|
|
long getDataOffset(const mz_zip_archive_file_stat& fileStat) const;
|
2025-12-03 22:00:29 +11:00
|
|
|
|
|
|
|
|
public:
|
2025-12-21 04:38:51 +01:00
|
|
|
explicit ZipFile(std::string filePath);
|
|
|
|
|
~ZipFile() { mz_zip_reader_end(&zipArchive); }
|
2025-12-13 19:36:01 +11:00
|
|
|
bool getInflatedFileSize(const char* filename, size_t* size) const;
|
2025-12-03 22:00:29 +11:00
|
|
|
uint8_t* readFileToMemory(const char* filename, size_t* size = nullptr, bool trailingNullByte = false) const;
|
2025-12-08 00:39:17 +11:00
|
|
|
bool readFileToStream(const char* filename, Print& out, size_t chunkSize) const;
|
2025-12-03 22:00:29 +11:00
|
|
|
};
|