CMS 3D CMS Logo

lat::ZipArchive Class Reference

Read and write members in a ZIP archive. More...

#include <Iguana/Utilities/classlib/zip/ZipArchive.h>

Inheritance diagram for lat::ZipArchive:

lat::ZConstants lat::ZipUtils

List of all members.

Public Types

typedef std::vector< ZipMember * >
::const_iterator 
Iterator

Public Member Functions

Iterator begin (void) const
void close (void)
void comment (const std::string &text)
std::string comment (void) const
Iterator end (void) const
Iterator find (Filename name) const
void flush (void)
InputStreaminput (ZipMember *member)
ZipMembermember (Filename name) const
StorageopenStored (ZipMember *member)
OutputStreamoutput (ZipMember *member)
size_t size (void) const
bool verify (void)
 ZipArchive (Filename name, unsigned mode)
 ZipArchive (Storage *file)
virtual ~ZipArchive (void)

Protected Member Functions

virtual StorageopenStored (Storage *master, IOOffset position, IOOffset length)

Private Member Functions

void closeArchive (void)
IOOffset findEndHeader (void)
void openArchive (void)
const ZipArchiveoperator= (const ZipArchive &)
void readDirectory (void)
void readEndHeader (IOOffset pos)
ZipMemberreadMember (void)
void updateMember (ZipMember *member)
bool verifyMember (void)
void writeDirectory (void)
 ZipArchive (const ZipArchive &)

Private Attributes

std::string m_comment
OutputStreamm_current
IOOffset m_dirOffset
IOOffset m_dirPos
IOOffset m_dirSize
Storagem_file
unsigned m_level
std::vector< ZipMember * > m_members
Method m_method
unsigned m_mode
 Current open mode.
IOOffset m_prefixSize

Friends

class SInput
class SOutput
class ZInput
class ZOutput


Detailed Description

Read and write members in a ZIP archive.

A ZIP archive consists of files compressed with the popular ZLIB compression algorithm. The archive format is used among others by PKZip and Info-ZIP. The compression algorithm is also used by GZIP and the PNG graphics standard. The format of the archives is explained briefly below. This class provides an interface to read and write such archives.

A ZIP archive contains a prefix, series of archive members (files), and a central directory. In theory the archive could span multiple disks (or files) with the central directory of the whole archive on the last disk, but this package does not support such multi-part archives. The prefix is only used in self-extracting executable archive files.

The member are stored in the archive sequentially, each with a local header followed by the compressed data; the local header describes the member, including its file name and compressed and real sizes. The central directory includes the member details again, plus allows an extra member comment to be added. The last member in the central directory is an end marker that can contain a comment for the whole archive. Both the local header and the central directory can also carry extra member-specific data; the data in the local and global parts can be different.

Once the archive has been opened, the client can query the members and read their contents by asking the archive for an input stream. The members can be accessed in any order, however only one member at a time should be read from. Trying to read data from more than one member at a time will confuse the internal file state. (FIXME: attempting to seek the underlying file storage behind the scenes will have similar impact.)

Archive writes are possible only in constrained sequential write of all members in one go. First create a in write mode. Next create a new , fully describing it in the constructor. Then retrieve the compressing output stream from the archive and write all the member file data to the stream. Once complete, close the stream, and repeat the whole process for subsequent files. Finally, the close or at least flush the archive itself. The writing is not thread safe, nor is it permitted to read from already-written members while writing.

The owns all the objects it returns as well as those added to it for write.

See also:
ZipInputStream, ZipOutputStream for simple stream-oriented reading and writing of ZIP archives.

Definition at line 76 of file ZipArchive.h.


Member Typedef Documentation

typedef std::vector<ZipMember *>::const_iterator lat::ZipArchive::Iterator

Definition at line 79 of file ZipArchive.h.


Constructor & Destructor Documentation

lat::ZipArchive::ZipArchive ( Storage file  ) 

lat::ZipArchive::ZipArchive ( Filename  name,
unsigned  mode 
)

virtual lat::ZipArchive::~ZipArchive ( void   )  [virtual]

lat::ZipArchive::ZipArchive ( const ZipArchive  )  [private]


Member Function Documentation

Iterator lat::ZipArchive::begin ( void   )  const

void lat::ZipArchive::close ( void   ) 

Referenced by edm::service::IguanaService::postEndJob().

void lat::ZipArchive::closeArchive ( void   )  [private]

void lat::ZipArchive::comment ( const std::string &  text  ) 

std::string lat::ZipArchive::comment ( void   )  const

Iterator lat::ZipArchive::end ( void   )  const

Iterator lat::ZipArchive::find ( Filename  name  )  const

IOOffset lat::ZipArchive::findEndHeader ( void   )  [private]

void lat::ZipArchive::flush ( void   ) 

InputStream* lat::ZipArchive::input ( ZipMember member  ) 

ZipMember* lat::ZipArchive::member ( Filename  name  )  const

void lat::ZipArchive::openArchive ( void   )  [private]

virtual Storage* lat::ZipArchive::openStored ( Storage master,
IOOffset  position,
IOOffset  length 
) [protected, virtual]

Storage* lat::ZipArchive::openStored ( ZipMember member  ) 

const ZipArchive& lat::ZipArchive::operator= ( const ZipArchive  )  [private]

OutputStream* lat::ZipArchive::output ( ZipMember member  ) 

Referenced by edm::service::IguanaService::postBeginJob(), edm::service::IguanaService::postEndJob(), edm::service::IguanaService::preEventProcessing(), edm::service::IguanaService::registry(), and edm::service::IguanaService::report().

void lat::ZipArchive::readDirectory ( void   )  [private]

void lat::ZipArchive::readEndHeader ( IOOffset  pos  )  [private]

ZipMember* lat::ZipArchive::readMember ( void   )  [private]

size_t lat::ZipArchive::size ( void   )  const

void lat::ZipArchive::updateMember ( ZipMember member  )  [private]

bool lat::ZipArchive::verify ( void   ) 

bool lat::ZipArchive::verifyMember ( void   )  [private]

void lat::ZipArchive::writeDirectory ( void   )  [private]


Friends And Related Function Documentation

friend class SInput [friend]

Definition at line 122 of file ZipArchive.h.

friend class SOutput [friend]

Definition at line 124 of file ZipArchive.h.

friend class ZInput [friend]

Definition at line 120 of file ZipArchive.h.

friend class ZOutput [friend]

Definition at line 123 of file ZipArchive.h.


Member Data Documentation

std::string lat::ZipArchive::m_comment [private]

Definition at line 141 of file ZipArchive.h.

OutputStream* lat::ZipArchive::m_current [private]

Definition at line 156 of file ZipArchive.h.

IOOffset lat::ZipArchive::m_dirOffset [private]

Definition at line 145 of file ZipArchive.h.

IOOffset lat::ZipArchive::m_dirPos [private]

Definition at line 143 of file ZipArchive.h.

IOOffset lat::ZipArchive::m_dirSize [private]

Definition at line 144 of file ZipArchive.h.

Storage* lat::ZipArchive::m_file [private]

Definition at line 138 of file ZipArchive.h.

unsigned lat::ZipArchive::m_level [private]

Definition at line 140 of file ZipArchive.h.

std::vector<ZipMember *> lat::ZipArchive::m_members [private]

Definition at line 155 of file ZipArchive.h.

Method lat::ZipArchive::m_method [private]

Definition at line 139 of file ZipArchive.h.

unsigned lat::ZipArchive::m_mode [private]

Current open mode.

Always has one of File::ModeRead, File::ModeWrite set (exactly one of them), except that internally the whole mode is set to zero to indicate closed archive. (Flags other than those two can be set by the client.)

Definition at line 148 of file ZipArchive.h.

IOOffset lat::ZipArchive::m_prefixSize [private]

Definition at line 142 of file ZipArchive.h.


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:48:45 2009 for CMSSW by  doxygen 1.5.4