Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ZipStatFilter Class Reference
Zip Code Zip Code » | Zip Code Internals

Helper class for tracking CRC and uncompressed size. More...

`#include <zipStatFilter.h>`

Inheritance diagram for ZipStatFilter:

## Public Member Functions
| ZipStatFilter ()
| ZipStatFilter (CentralDir *cd)
virtual | ~ZipStatFilter ()
virtual bool | attachStream (Stream *stream)
virtual void | detachStream ()
virtual Stream * | getStream ()
void | setCentralDir (CentralDir *cd)
CentralDir * | getCentralDir ()
Public Member Functions inherited from FilterStream
virtual | ~FilterStream ()
bool | hasCapability (const Capability) const
| Checks to see if this stream has the capability of a given function. More...
U32 | getPosition () const
| Gets the position in the stream. More...
bool | setPosition (const U32 in_newPosition)
| Sets the position of the stream. Returns if the new position is valid or not. More...
U32 | getStreamSize ()
| Gets the size of the stream. More...
Public Member Functions inherited from Stream
| Stream ()
virtual | ~Stream ()
Stream::Status | getStatus () const
| Gets the status of the stream. More...
void | readLine (U8 *buffer, U32 bufferSize)
void | writeLine (U8 *buffer)
| writes a line to the stream More...
const char * | readSTString (bool casesens=false)
virtual void | readString (char stringBuf[256])
| Reads a string of maximum 255 characters long. More...
void | readLongString (U32 maxStringLen, char *stringBuf)
void | writeLongString (U32 maxStringLen, const char *string)
bool | Put (char character)
virtual void | writeString (const char *stringBuf, S32 maxLen=255)
| Writes a string to the stream. More...
bool | writeFormattedBuffer (const char *format,...)
bool | writeStringBuffer (const char *buffer)
| Writes a NULL terminated string buffer. More...
bool | write (const ColorI &)
| Write an integral color to the stream. More...
bool | write (const ColorF &)
| Write a floating point color to the stream. More...
bool | read (ColorI *)
| Read an integral color from the stream. More...
bool | read (ColorF *)
| Read a floating point color from the stream. More...
bool | read (const U32 in_numBytes, void *out_pBuffer)
bool | write (const U32 in_numBytes, const void *in_pBuffer)
bool | read (bool *out_pRead)
bool | write (const bool &in_rWrite)
bool | copyFrom (Stream *other)
| Copy the contents of another stream into this one. More...
void | writeTabs (U32 count)
| Write a number of tabs to this stream. More...

## Protected Member Functions
virtual bool | _write (const U32 numBytes, const void *buffer)
virtual bool | _read (const U32 numBytes, void *buffer)
Protected Member Functions inherited from Stream
void | setStatus (const Status in_newStatus)

## Protected Attributes
Stream * | mStream
CentralDir * | mCD

## Additional Inherited Members
Public Types inherited from Stream
enum | Status { Ok = 0, IOError, EOS, IllegalCall, Closed, UnknownError }
| Status constantants for the stream. More...
enum | Capability { StreamWrite = BIT(0), StreamRead = BIT(1), StreamPosition = BIT(2) }
Static Public Member Functions inherited from Stream
static const char * | getStatusString (const Status in_status)
| Gets a printable string form of the status. More...

## 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

## Constructor & Destructor Documentation

ZipStatFilter | ( |  | ) |
| inline

ZipStatFilter | ( | CentralDir * | cd | ) |
| inline

virtual ~ZipStatFilter | ( |  | ) |
| inline virtual

## Member Function Documentation

virtual bool _read | ( | const U32 | numBytes,
|  | void * | buffer
| ) |  |
| inline protected virtual

Reimplemented from FilterStream.

virtual bool _write | ( | const U32 | numBytes,
|  | const void * | buffer
| ) |  |
| inline protected virtual

Reimplemented from FilterStream.

virtual bool attachStream | ( | Stream * | stream | ) |
| inline virtual

Implements FilterStream.

virtual void detachStream | ( |  | ) |
| inline virtual

Implements FilterStream.

CentralDir* getCentralDir | ( |  | ) |
| inline

virtual Stream* getStream | ( |  | ) |
| inline virtual

Implements FilterStream.

void setCentralDir | ( | CentralDir * | cd | ) |
| inline

## Member Data Documentation

CentralDir* mCD
| protected

Stream* mStream
| protected

The documentation for this class was generated from the following file:

- io/zip/zipStatFilter.h