38#ifndef __ZipFileIterator_h
39#define __ZipFileIterator_h
41#include <HttpServer.h>
46struct ZipFileHeaderData;
74 ZipReader(CspReader_Read r, U32 zipFileSize);
85BA_API
void ZipReader_constructor(
86 ZipReader* o, CspReader_Read r, U32 zipFileSize);
89inline ZipReader::ZipReader(CspReader_Read r, U32 zipFileSize) {
90 ZipReader_constructor(
this, r, zipFileSize); }
105 ZipComprMethod_Stored=0,
106 ZipComprMethod_Deflated=8,
107 ZipComprMethod_AES=99
113typedef struct ZipFileHeader
118 const char* getAESef();
123 ZipComprMethod getComprMethod();
124 U32 getUncompressedSizeLittleEndian();
125 U32 getCrc32LittleEndian();
126 U32 getCompressedSize();
127 U32 getUncompressedSize();
129 static const char* e2str(ZipErr e);
130 U16 getVersionMade();
134 CspReader* getReader();
137 struct ZipFileHeaderData* data;
145 ZipComprMethod comprMethod;
154#define ZipFileHeader_getFn(o) (o)->fn
155#define ZipFileHeader_getEf(o) (o)->ef
156#define ZipFileHeader_getAESef(o) (o)->AESef
157#define ZipFileHeader_isDirectory(o) ((o)->fn[(o)->fnLen-1] == '/')
158#define ZipFileHeader_getFnLen(o) (o)->fnLen
159#define ZipFileHeader_getEfLen(o) (o)->efLen
160#define ZipFileHeader_getFcLen(o) (o)->fcLen
161#define ZipFileHeader_getComprMethod(o) (o)->comprMethod
162#define ZipFileHeader_getReader(o) (CspReader*)(o)->reader
163BA_API U32 ZipFileHeader_getUncompressedSizeLittleEndian(ZipFileHeader* o);
164BA_API U32 ZipFileHeader_getCrc32LittleEndian(ZipFileHeader* o);
165BA_API U32 ZipFileHeader_getCompressedSize(ZipFileHeader* o);
166BA_API U32 ZipFileHeader_getUncompressedSize(ZipFileHeader* o);
167BA_API U32 ZipFileHeader_getCrc32(ZipFileHeader* o);
168BA_API
const char* ZipFileHeader_e2str(ZipErr e);
171BA_API U16 ZipFileHeader_getVersionMade(ZipFileHeader* o);
181BA_API U16 ZipFileHeader_getFlag(ZipFileHeader* o);
183BA_API U32 ZipFileHeader_getDataOffset(ZipFileHeader* o);
184BA_API U32 ZipFileHeader_getTime(ZipFileHeader* o);
188inline const char* ZipFileHeader::getFn() {
189 return ZipFileHeader_getFn(
this);
191inline const char* ZipFileHeader::getEf() {
192 return (
char*)ZipFileHeader_getEf(
this);
194inline const char* ZipFileHeader::getAESef() {
195 return (
char*)ZipFileHeader_getAESef(
this);
197inline bool ZipFileHeader::isDirectory() {
198 return ZipFileHeader_isDirectory(
this) ? true :
false;
200inline U16 ZipFileHeader::getFnLen() {
201 return ZipFileHeader_getFnLen(
this);
203inline U16 ZipFileHeader::getEfLen() {
204 return ZipFileHeader_getEfLen(
this);
206inline U16 ZipFileHeader::getFcLen() {
207 return ZipFileHeader_getFcLen(
this);
209inline ZipComprMethod ZipFileHeader::getComprMethod() {
210 return ZipFileHeader_getComprMethod(
this);
212inline CspReader* ZipFileHeader::getReader() {
213 return ZipFileHeader_getReader(
this);
215inline U32 ZipFileHeader::getUncompressedSizeLittleEndian() {
216 return ZipFileHeader_getUncompressedSizeLittleEndian(
this);
218inline U32 ZipFileHeader::getCrc32LittleEndian() {
219 return ZipFileHeader_getCrc32LittleEndian(
this);
221inline U32 ZipFileHeader::getCompressedSize() {
222 return ZipFileHeader_getCompressedSize(
this);
224inline U32 ZipFileHeader::getUncompressedSize() {
225 return ZipFileHeader_getUncompressedSize(
this);
227inline U32 ZipFileHeader::getCrc32() {
228 return ZipFileHeader_getCrc32(
this);
230inline const char* ZipFileHeader::e2str(ZipErr e) {
231 return ZipFileHeader_e2str(e);
233inline U16 ZipFileHeader::getVersionMade() {
234 return ZipFileHeader_getVersionMade(
this);
236inline U16 ZipFileHeader::getFlag() {
237 return ZipFileHeader_getFlag(
this);
239inline U32 ZipFileHeader::getDataOffset() {
240 return ZipFileHeader_getDataOffset(
this);
242inline U32 ZipFileHeader::getTime() {
243 return ZipFileHeader_getTime(
this);
256 U32 uncompressedSize;
259 ZipComprMethod comprMethod;
265#if defined(B_LITTLE_ENDIAN)
266#define ZipFileInfo_makeLittleEndianU32(x) x
267#elif defined(B_BIG_ENDIAN)
268#define ZipFileInfo_makeLittleEndianU32(x) \
269 ((U32)((((U32)(x) & 0x000000ffU) << 24) | \
270 (((U32)(x) & 0x0000ff00U) << 8) | \
271 (((U32)(x) & 0x00ff0000U) >> 8) | \
272 (((U32)(x) & 0xff000000U) >> 24)))
274#error in config/make file, you must define one of B_LITTLE_ENDIAN or B_BIG_ENDIAN
277#define ZipFileInfo_getCrc32LittleEndian(o) \
278 ZipFileInfo_makeLittleEndianU32((o)->crc32);
279#define ZipFileInfo_getUncompressedSizeLittleEndian(o) \
280 ZipFileInfo_makeLittleEndianU32((o)->uncompressedSize);
283#define ZipFileInfo_constructor(o, fileHeader, EfPtr) \
285 (o)->crc32 = ZipFileHeader_getCrc32(fileHeader); \
286 (o)->dataOffset = ZipFileHeader_getDataOffset(fileHeader); \
287 (o)->uncompressedSize = ZipFileHeader_getUncompressedSize(fileHeader); \
288 (o)->compressedSize = ZipFileHeader_getCompressedSize(fileHeader); \
289 (o)->time = ZipFileHeader_getTime(fileHeader); \
290 (o)->comprMethod = ZipFileHeader_getComprMethod(fileHeader); \
291 (o)->flag = ZipFileHeader_getFlag(fileHeader); \
293 (o)->AESef = (EfPtr + (ZipFileHeader_getAESef(fileHeader) - ZipFileHeader_getEf(fileHeader))); \
301 U32 uncompressedSize;
303 ZipComprMethod comprMethod;
307#define MiniZipFileInfo_constructor(o, fileHeader) \
309 (o)->dataOffset = ZipFileHeader_getDataOffset(fileHeader); \
310 (o)->uncompressedSize = ZipFileHeader_getUncompressedSize(fileHeader); \
311 (o)->compressedSize = ZipFileHeader_getCompressedSize(fileHeader); \
312 (o)->comprMethod = ZipFileHeader_getComprMethod(fileHeader); \
326 ZipFileHeader* getElement();
330 ZipFileHeader fileHeader;
331 U32 curFileHeaderOffs;
340#define CentralDirIterator_getECode(o) (o)->err
348 U8* buf, U32 bufSize);
353inline CentralDirIterator::CentralDirIterator(
ZipContainer* container) {
354 CentralDirIterator_constructor(
this, container);
356inline CentralDirIterator::CentralDirIterator(
358 CentralDirIterator_constructorR(
this, container, buf, bufSize);
360inline ZipErr CentralDirIterator::getECode() {
361 return CentralDirIterator_getECode(
this);
363inline ZipFileHeader* CentralDirIterator::getElement() {
364 return CentralDirIterator_getElement(
this);
366inline bool CentralDirIterator::nextElement() {
367 return CentralDirIterator_nextElement(
this) ? true :
false;
382 void *
operator new(
size_t s) { return ::baMalloc(s); }
383 void operator delete(
void* d) {
if(d) ::baFree(d); }
384 void *
operator new(size_t,
void *place) {
return place; }
385 void operator delete(
void*,
void *) { }
413#define ZipContainer_getECode(o) (o)->errCode
416inline ZipContainer::ZipContainer(
ZipReader* reader, U8* buf, U32 bufSize) {
417 ZipContainer_constructor(
this,reader,buf,bufSize); }
418inline ZipErr ZipContainer::getECode() {
419 return ZipContainer_getECode(
this); }
422int initGZipHeader(
struct ZipFileInfo* zfi, GzipHeader* gzipH);
struct ZipContainer ZipContainer
A ZipContainer is a buffer used by a ZipIo when reading data from a ZipReader.
struct CentralDirIterator CentralDirIterator
Low level ZIP file central directory iterator.
struct ZipFileInfo ZipFileInfo
Low level ZIP file information used internally by the Zip File System.
Low level ZIP file central directory iterator.
Definition: ZipFileIterator.h:321
A ZipContainer is a buffer used by a ZipIo when reading data from a ZipReader.
Definition: ZipFileIterator.h:379
Low level ZIP file information used internally by the Zip File System.
Definition: ZipFileIterator.h:253
Abstract interface class for reading a ZipFile.
Definition: ZipFileIterator.h:72