ROOT
6.06/09
Reference Guide
|
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.
Definition at line 22 of file TZIPFile.h.
Public Member Functions | |
TZIPFile () | |
TZIPFile (const char *archive, const char *member, TFile *file) | |
Specify the archive name and member name. More... | |
virtual | ~TZIPFile () |
virtual Int_t | OpenArchive () |
Open archive and read end-header and directory. More... | |
virtual Int_t | SetCurrentMember () |
Find the desired member in the member array and make it the current member. More... | |
void | Print (Option_t *option="") const |
Pretty print ZIP archive members. More... | |
Public Member Functions inherited from TArchiveFile | |
TArchiveFile () | |
TArchiveFile (const char *archive, const char *member, TFile *file) | |
virtual | ~TArchiveFile () |
Dtor. More... | |
virtual Int_t | SetMember (const char *member) |
Explicitely make the specified member the current member. More... | |
virtual Int_t | SetMember (Int_t idx) |
Explicitely make the member with the specified index the current member. More... | |
Long64_t | GetMemberFilePosition () const |
Return position in archive of current member. More... | |
TArchiveMember * | GetMember () const |
TObjArray * | GetMembers () const |
Int_t | GetNumberOfMembers () const |
Returns number of members in archive. More... | |
const char * | GetArchiveName () const |
const char * | GetMemberName () const |
Int_t | GetMemberIndex () const |
Public Member Functions inherited from TObject | |
TObject () | |
TObject (const TObject &object) | |
TObject copy ctor. More... | |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. More... | |
virtual | ~TObject () |
TObject destructor. More... | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. More... | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. More... | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. More... | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. More... | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. More... | |
virtual void | Copy (TObject &object) const |
Copy this to obj. More... | |
virtual void | Delete (Option_t *option="") |
Delete this object. More... | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. More... | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. More... | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. More... | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current pad. More... | |
virtual void | Dump () const |
Dump contents of object on stdout. More... | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. More... | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). More... | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. More... | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. More... | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. More... | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. More... | |
virtual const char * | GetName () const |
Returns name of object. More... | |
virtual const char * | GetIconName () const |
Returns mime type name of object. More... | |
virtual Option_t * | GetOption () const |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). More... | |
virtual const char * | GetTitle () const |
Returns title of object. More... | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. More... | |
virtual ULong_t | Hash () const |
Return hash value for this object. More... | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". More... | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. More... | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. More... | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More... | |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). More... | |
virtual Bool_t | IsSortable () const |
Bool_t | IsOnHeap () const |
Bool_t | IsZombie () const |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. More... | |
virtual void | ls (Option_t *option="") const |
The ls function lists the contents of a class on stdout. More... | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. More... | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. More... | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. More... | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. More... | |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. More... | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". More... | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. More... | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. More... | |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. More... | |
void * | operator new (size_t sz) |
void * | operator new[] (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz, void *vp) |
void | operator delete (void *ptr) |
Operator delete. More... | |
void | operator delete[] (void *ptr) |
Operator delete []. More... | |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. More... | |
void | SetBit (UInt_t f) |
void | ResetBit (UInt_t f) |
Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
void | InvertBit (UInt_t f) |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. More... | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. More... | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. More... | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. More... | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. More... | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. More... | |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More... | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. More... | |
Protected Member Functions | |
Long64_t | FindEndHeader () |
Find the end header of the ZIP archive. Returns 0 in case of error. More... | |
Int_t | ReadEndHeader (Long64_t pos) |
Read the end header of the ZIP archive including the archive comment at the current file position. More... | |
Long64_t | ReadZip64EndLocator (Long64_t pos) |
Read Zip64 end of central directory locator. More... | |
Int_t | ReadZip64EndRecord (Long64_t pos) |
Read Zip64 end of central directory record. More... | |
Int_t | ReadDirectory () |
Read the directory of the ZIP archive. More... | |
Int_t | ReadMemberHeader (TZIPMember *member) |
Read the member header of the ZIP archive. More... | |
UInt_t | Get (const void *buffer, Int_t bytes) |
Read a "bytes" long little-endian integer value from "buffer". More... | |
ULong64_t | Get64 (const void *buffer, Int_t bytes) |
Read a 8 byte long little-endian integer value from "buffer". More... | |
Int_t | DecodeZip64ExtendedExtraField (TZIPMember *m, Bool_t global=kTRUE) |
Decode the Zip64 extended extra field. More... | |
TZIPFile (const TZIPFile &) | |
TZIPFile & | operator= (const TZIPFile &) |
Protected Member Functions inherited from TObject | |
void | MakeZombie () |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). More... | |
Protected Attributes | |
Long64_t | fDirPos |
Central directory position. More... | |
Long64_t | fDirSize |
Central directory size. More... | |
Long64_t | fDirOffset |
Central directory offset (from the beginning of the archive) More... | |
TString | fComment |
Archive comment. More... | |
Protected Attributes inherited from TArchiveFile | |
TString | fArchiveName |
Archive file name. More... | |
TString | fMemberName |
Sub-file name. More... | |
Int_t | fMemberIndex |
Index of sub-file in archive. More... | |
TFile * | fFile |
File stream used to access the archive. More... | |
TObjArray * | fMembers |
Members in this archive. More... | |
TArchiveMember * | fCurMember |
Current archive member. More... | |
Additional Inherited Members | |
Public Types inherited from TObject | |
enum | EStatusBits { kCanDelete = BIT(0), kMustCleanup = BIT(3), kObjInCanvas = BIT(3), kIsReferenced = BIT(4), kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13) } |
enum | { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) } |
Static Public Member Functions inherited from TArchiveFile | |
static TArchiveFile * | Open (const char *url, TFile *file) |
Return proper archive file handler depending on passed url. More... | |
Static Public Member Functions inherited from TObject | |
static Long_t | GetDtorOnly () |
Return destructor only flag. More... | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. More... | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. More... | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. More... | |
Static Protected Member Functions inherited from TArchiveFile | |
static Bool_t | ParseUrl (const char *url, TString &archive, TString &member, TString &type) |
Try to determine if url contains an anchor specifying an archive member. More... | |
#include <TZIPFile.h>
|
protected |
ZIP archive constants.
Definition at line 41 of file TZIPFile.h.
|
protected |
TZIPFile::TZIPFile | ( | ) |
TZIPFile::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.
Definition at line 76 of file TZIPFile.cxx.
|
inlinevirtual |
Definition at line 139 of file TZIPFile.h.
|
protected |
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.
Definition at line 441 of file TZIPFile.cxx.
Referenced by ReadDirectory().
|
protected |
Find the end header of the ZIP archive. Returns 0 in case of error.
Definition at line 98 of file TZIPFile.cxx.
Referenced by OpenArchive().
Read a "bytes" long little-endian integer value from "buffer".
Definition at line 514 of file TZIPFile.cxx.
Referenced by DecodeZip64ExtendedExtraField(), ReadDirectory(), ReadEndHeader(), ReadMemberHeader(), ReadZip64EndLocator(), and ReadZip64EndRecord().
Read a 8 byte long little-endian integer value from "buffer".
Definition at line 535 of file TZIPFile.cxx.
Referenced by DecodeZip64ExtendedExtraField(), ReadZip64EndLocator(), and ReadZip64EndRecord().
|
virtual |
Open archive and read end-header and directory.
Returns -1 in case of error, 0 otherwise.
Implements TArchiveFile.
Definition at line 88 of file TZIPFile.cxx.
Pretty print ZIP archive members.
Reimplemented from TObject.
Definition at line 557 of file TZIPFile.cxx.
|
protected |
Read the directory of the ZIP archive.
Returns -1 in case of error, 0 otherwise.
Definition at line 278 of file TZIPFile.cxx.
Referenced by OpenArchive().
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.
Definition at line 139 of file TZIPFile.cxx.
Referenced by OpenArchive().
|
protected |
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.
Definition at line 404 of file TZIPFile.cxx.
Referenced by SetCurrentMember().
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.
Definition at line 211 of file TZIPFile.cxx.
Referenced by ReadEndHeader().
Read Zip64 end of central directory record.
Returns -1 in case of error and 0 in case of success.
Definition at line 246 of file TZIPFile.cxx.
Referenced by ReadEndHeader().
|
virtual |
Find the desired member in the member array and make it the current member.
Returns -1 in case member is not found, 0 otherwise.
Implements TArchiveFile.
Definition at line 486 of file TZIPFile.cxx.
|
protected |
Archive comment.
Definition at line 28 of file TZIPFile.h.
Referenced by ClassImp(), and ReadEndHeader().
|
protected |
Central directory offset (from the beginning of the archive)
Definition at line 27 of file TZIPFile.h.
Referenced by ReadEndHeader(), ReadZip64EndRecord(), and TZIPFile().
|
protected |
Central directory position.
Definition at line 25 of file TZIPFile.h.
Referenced by ReadDirectory(), ReadEndHeader(), ReadZip64EndRecord(), and TZIPFile().
|
protected |
Central directory size.
Definition at line 26 of file TZIPFile.h.
Referenced by ReadEndHeader(), ReadZip64EndRecord(), and TZIPFile().