ROOT logo
ROOT » IO » IO » TZIPFile

class TZIPFile: public TArchiveFile


TZIPFile

This class describes a ZIP archive file containing multiple
sub-files. Typically the sub-files are ROOT files. Notice that
the ROOT files should not be compressed when being added to the
ZIP file, since ROOT files are normally already compressed.
Such a ZIP file should be created like:

zip -n root multi file1.root file2.root

which creates a ZIP file multi.zip.

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
such archives.

A ZIP archive contains a prefix, series of archive members
(sub-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 class does not support
such multi-part archives. The prefix is only used in self-extracting
executable archive files.

The members are stored in the archive sequentially, each with a
local header followed by the (optionally) 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.
The fact that the archive has a global directory makes it efficient
and allows for only the reading of the desired data, one does not
have to scan through the whole file to find the desired sub-file.
The Zip64 extensions are supported so files larger than 2GB can be
stored in archives larger than 4 GB.

Once the archive has been opened, the client can query the members
and read their contents by asking the archive for an offset where
the sub-file starts. The members can be accessed in any order.


Function Members (Methods)

public:
TZIPFile()
TZIPFile(const char* archive, const char* member, TFile* file)
virtual~TZIPFile()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
const char*TArchiveFile::GetArchiveName() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
TArchiveMember*TArchiveFile::GetMember() const
Long64_tTArchiveFile::GetMemberFilePosition() const
Int_tTArchiveFile::GetMemberIndex() const
const char*TArchiveFile::GetMemberName() const
TObjArray*TArchiveFile::GetMembers() const
virtual const char*TObject::GetName() const
Int_tTArchiveFile::GetNumberOfMembers() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static TArchiveFile*TArchiveFile::Open(const char* url, TFile* file)
virtual Int_tOpenArchive()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual Int_tSetCurrentMember()
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual Int_tTArchiveFile::SetMember(const char* member)
virtual Int_tTArchiveFile::SetMember(Int_t idx)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector&)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
TZIPFile(const TZIPFile&)
Int_tDecodeZip64ExtendedExtraField(TZIPMember* m, Bool_t global = kTRUE)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
Long64_tFindEndHeader()
UInt_tGet(const void* buffer, Int_t bytes)
ULong64_tGet64(const void* buffer, Int_t bytes)
voidTObject::MakeZombie()
TZIPFile&operator=(const TZIPFile&)
static Bool_tTArchiveFile::ParseUrl(const char* url, TString& archive, TString& member, TString& type)
Int_tReadDirectory()
Int_tReadEndHeader(Long64_t pos)
Int_tReadMemberHeader(TZIPMember* member)
Long64_tReadZip64EndLocator(Long64_t pos)
Int_tReadZip64EndRecord(Long64_t pos)

Data Members

public:
enum EZIPConstants { kARCHIVE_VERSION
kDIR_HEADER_MAGIC
kENTRY_HEADER_MAGIC
kEND_HEADER_MAGIC
kZIP64_EDR_HEADER_MAGIC
kZIP64_EDL_HEADER_MAGIC
kZIP64_EXTENDED_MAGIC
kZIP_MAGIC_LEN
kMAX_VAR_LEN
kMAX_SIZE
kDIR_MAGIC_OFF
kDIR_VMADE_OFF
kDIR_VMADE_LEN
kDIR_VREQD_OFF
kDIR_VREQD_LEN
kDIR_FLAG_OFF
kDIR_FLAG_LEN
kDIR_METHOD_OFF
kDIR_METHOD_LEN
kDIR_DATE_OFF
kDIR_DATE_LEN
kDIR_CRC32_OFF
kDIR_CRC32_LEN
kDIR_CSIZE_OFF
kDIR_CSIZE_LEN
kDIR_USIZE_OFF
kDIR_USIZE_LEN
kDIR_NAMELEN_OFF
kDIR_NAMELEN_LEN
kDIR_EXTRALEN_OFF
kDIR_EXTRALEN_LEN
kDIR_COMMENTLEN_OFF
kDIR_COMMENTLEN_LEN
kDIR_DISK_START_OFF
kDIR_DISK_START_LEN
kDIR_INT_ATTR_OFF
kDIR_INT_ATTR_LEN
kDIR_EXT_ATTR_OFF
kDIR_EXT_ATTR_LEN
kDIR_ENTRY_POS_OFF
kDIR_ENTRY_POS_LEN
kDIR_HEADER_SIZE
kZIP64_EDR_MAGIC_OFF
kZIP64_EDR_SIZE_OFF
kZIP64_EDR_SIZE_LEN
kZIP64_EDR_VERS_MADE_OFF
kZIP64_EDR_VERS_MADE_LEN
kZIP64_EDR_VERS_EXT_OFF
kZIP64_EDR_VERS_EXT_LEN
kZIP64_EDR_DISK_OFF
kZIP64_EDR_DISK_LEN
kZIP64_EDR_DIR_DISK_OFF
kZIP64_EDR_DIR_DISK_LEN
kZIP64_EDR_DISK_HDRS_OFF
kZIP64_EDR_DISK_HDRS_LEN
kZIP64_EDR_TOTAL_HDRS_OFF
kZIP64_EDR_TOTAL_HDRS_LEN
kZIP64_EDR_DIR_SIZE_OFF
kZIP64_EDR_DIR_SIZE_LEN
kZIP64_EDR_DIR_OFFSET_OFF
kZIP64_EDR_DIR_OFFSET_LEN
kZIP64_EDR_HEADER_SIZE
kZIP64_EDL_MAGIC_OFF
kZIP64_EDL_DISK_OFF
kZIP64_EDL_DISK_LEN
kZIP64_EDL_REC_OFFSET_OFF
kZIP64_EDL_REC_OFFSET_LEN
kZIP64_EDL_TOTAL_DISK_OFF
kZIP64_EDL_TOTAL_DISK_LEN
kZIP64_EDL_HEADER_SIZE
kEND_MAGIC_OFF
kEND_DISK_OFF
kEND_DISK_LEN
kEND_DIR_DISK_OFF
kEND_DIR_DISK_LEN
kEND_DISK_HDRS_OFF
kEND_DISK_HDRS_LEN
kEND_TOTAL_HDRS_OFF
kEND_TOTAL_HDRS_LEN
kEND_DIR_SIZE_OFF
kEND_DIR_SIZE_LEN
kEND_DIR_OFFSET_OFF
kEND_DIR_OFFSET_LEN
kEND_COMMENTLEN_OFF
kEND_COMMENTLEN_LEN
kEND_HEADER_SIZE
kENTRY_MAGIC_OFF
kENTRY_VREQD_OFF
kENTRY_VREQD_LEN
kENTRY_FLAG_OFF
kENTRY_FLAG_LEN
kENTRY_METHOD_OFF
kENTRY_METHOD_LEN
kENTRY_DATE_OFF
kENTRY_DATE_LEN
kENTRY_CRC32_OFF
kENTRY_CRC32_LEN
kENTRY_CSIZE_OFF
kENTRY_CSIZE_LEN
kENTRY_USIZE_OFF
kENTRY_USIZE_LEN
kENTRY_NAMELEN_OFF
kENTRY_NAMELEN_LEN
kENTRY_EXTRALEN_OFF
kENTRY_EXTRALEN_LEN
kENTRY_HEADER_SIZE
kZIP64_EXTENDED_MAGIC_OFF
kZIP64_EXTENDED_MAGIC_LEN
kZIP64_EXTENDED_SIZE_OFF
kZIP64_EXTENDED_SIZE_LEN
kZIP64_EXTENDED_USIZE_OFF
kZIP64_EXTENDED_USIZE_LEN
kZIP64_EXTENTED_CSIZE_OFF
kZIP64_EXTENDED_CSIZE_LEN
kZIP64_EXTENDED_HDR_OFFSET_OFF
kZIP64_EXTENDED_HDR_OFFSET_LEN
kZIP64_EXTENDED_DISK_OFF
kZIP64_EXTENDED_DISK_LEN
kZIP64_EXTENDED_SIZE
kSTORED
kDEFLATED
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
TStringTArchiveFile::fArchiveNameArchive file name
TStringfCommentArchive comment
TArchiveMember*TArchiveFile::fCurMemberCurrent archive member
Long64_tfDirOffsetCentral directory offset (from the beginning of the archive)
Long64_tfDirPosCentral directory position
Long64_tfDirSizeCentral directory size
TFile*TArchiveFile::fFileFile stream used to access the archive
Int_tTArchiveFile::fMemberIndexIndex of sub-file in archive
TStringTArchiveFile::fMemberNameSub-file name
TObjArray*TArchiveFile::fMembersMembers in this archive

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TZIPFile()
 Default ctor.
TZIPFile(const char* archive, const char* member, TFile* file)
 Specify the archive name and member name. The member can be a decimal
 number which allows to access the n-th member.
Int_t OpenArchive()
 Open archive and read end-header and directory. Returns -1 in case
 of error, 0 otherwise.
Long64_t FindEndHeader()
 Find the end header of the ZIP archive. Returns 0 in case of error.
Int_t ReadEndHeader(Long64_t pos)
 Read the end header of the ZIP archive including the archive comment
 at the current file position. Check that it really was a single-disk
 archive with all the entries as expected. Most importantly, figure
 out where the central directory begins. Returns -1 in case of error,
 0 otherwise.
Long64_t ReadZip64EndLocator(Long64_t pos)
 Read Zip64 end of central directory locator. Returns -1 in case of error,
 -2 in case end locator magic is not found (i.e. not a zip64 file) and
 offset of Zip64 end of central directory record in case of success.
Int_t ReadZip64EndRecord(Long64_t pos)
 Read Zip64 end of central directory record. Returns -1 in case of error
 and 0 in case of success.
Int_t ReadDirectory()
 Read the directory of the ZIP archive. Returns -1 in case of error,
 0 otherwise.
Int_t ReadMemberHeader(TZIPMember* member)
 Read the member header of the ZIP archive. Sets the position where
 the data starts in the member object. Returns -1 in case of error,
 0 otherwise.
Int_t DecodeZip64ExtendedExtraField(TZIPMember* m, Bool_t global = kTRUE)
 Decode the Zip64 extended extra field. If global is true, decode the
 extra field coming from the central directory, if false decode the
 extra field coming from the local file header. Returns -1 in case of
 error, -2 in case Zip64 extra block was not found and 0 in case of
 success.
Int_t SetCurrentMember()
 Find the desired member in the member array and make it the
 current member. Returns -1 in case member is not found, 0 otherwise.
UInt_t Get(const void* buffer, Int_t bytes)
 Read a "bytes" long little-endian integer value from "buffer".
ULong64_t Get64(const void* buffer, Int_t bytes)
 Read a 8 byte long little-endian integer value from "buffer".
void Print(Option_t* option = "") const
 Pretty print ZIP archive members.
TZIPFile(const TZIPFile& )
TZIPFile& operator=(const TZIPFile& )
virtual ~TZIPFile()
{ }