mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
Still a bit raw, but gets the time required to determine the size of each chapter (for reading progress) down from ~25ms to 0-1ms. This is done by keeping the zipArchive open (so simple ;)). Probably we don't need to cache the spine sizes anymore then... --------- Co-authored-by: Dave Allie <dave@daveallie.com>
21 lines
678 B
C++
21 lines
678 B
C++
#pragma once
|
|
#include <Print.h>
|
|
|
|
#include <string>
|
|
|
|
#include "miniz.h"
|
|
|
|
class ZipFile {
|
|
std::string filePath;
|
|
mutable mz_zip_archive zipArchive = {};
|
|
bool loadFileStat(const char* filename, mz_zip_archive_file_stat* fileStat) const;
|
|
long getDataOffset(const mz_zip_archive_file_stat& fileStat) const;
|
|
|
|
public:
|
|
explicit ZipFile(std::string filePath);
|
|
~ZipFile() { mz_zip_reader_end(&zipArchive); }
|
|
bool getInflatedFileSize(const char* filename, size_t* size) const;
|
|
uint8_t* readFileToMemory(const char* filename, size_t* size = nullptr, bool trailingNullByte = false) const;
|
|
bool readFileToStream(const char* filename, Print& out, size_t chunkSize) const;
|
|
};
|