Torque3D Documentation / _generateds / Zip::ZipStatFilter

Zip::ZipStatFilter

Engine/source/core/util/zip/zipStatFilter.h

Helper class for tracking CRC and uncompressed size.

More...

Private Types

Parent 

Protected Attributes

Protected Functions

bool
_read(const U32 numBytes, void * buffer)
bool
_write(const U32 numBytes, const void * buffer)

Detailed Description

Helper class for tracking CRC and uncompressed size.

ZipStatFilter allows us to track CRC and uncompressed size on the fly. This is necessary when dealing with compressed files as the CRC must be of the uncompressed data.

ZipStatFilter is mostly intended for internal use by the zip code. However, it can be useful when reading zips sequentially using the stream interface to provide CRC checking.

Example

// It's assumed that you would use proper error checking and that
// zip is a valid pointer to a ZipArchive and otherStream is a pointer
// to a valid stream.
Zip::ZipArchive *zip;
Stream *otherStream;

// We need the real central directory to compare the CRC32
Zip::CentralDir *realCD = zip->findFileInfo("file.txt");
Stream *stream = zip->openFile("file.txt", ZipArchive::Read);

Zip::CentralDir fakeCD;
Zip::ZipStatFilter zsf(&fakeCD);

zsf.attachStream(stream);

// ... read <i>entire</i> file sequentially using zsf instead of stream
otherStream->copyFrom(&zsf);

zsf.detachStream();

// fakeCD.mCRC32 now contains the CRC32 of the stream
if(fakeCD.mCRC32 != realCD->mCRC32)
{
   // ... handle CRC failure ...
}

zip->closeFile(stream);

A more complete example of this may be found in the code for the ZipArchive::extractFile() method in zipArchive.cc

Private Types

typedef FilterStream Parent 

Protected Attributes

CentralDir * mCD 
Stream * mStream 

Protected Functions

_read(const U32 numBytes, void * buffer)

Reimplemented from: FilterStream

_write(const U32 numBytes, const void * buffer)

Reimplemented from: FilterStream

Public Functions

ZipStatFilter()

ZipStatFilter(CentralDir * cd)

~ZipStatFilter()

attachStream(Stream * stream)

Reimplemented from: FilterStream

detachStream()

Reimplemented from: FilterStream

getCentralDir()

getStream()

Reimplemented from: FilterStream

setCentralDir(CentralDir * cd)