Logo ROOT   6.14/05
Reference Guide
TZIPFile.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Fons Rademakers 30/6/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TZIPFile
13 #define ROOT_TZIPFile
14 
15 #include "TArchiveFile.h"
16 
17 class TZIPMember;
18 
19 
20 class TZIPFile : public TArchiveFile {
21 
22 protected:
23  Long64_t fDirPos; ///< Central directory position
24  Long64_t fDirSize; ///< Central directory size
25  Long64_t fDirOffset; ///< Central directory offset (from the beginning of the archive)
26  TString fComment; ///< Archive comment
27 
34  UInt_t Get(const void *buffer, Int_t bytes);
35  ULong64_t Get64(const void *buffer, Int_t bytes);
37 
38  /// ZIP archive constants
40  // - Archive version required (and made)
42 
43  // - Magic header constants
44  kDIR_HEADER_MAGIC = 0x02014b50,
45  kENTRY_HEADER_MAGIC = 0x04034b50,
46  kEND_HEADER_MAGIC = 0x06054b50,
49  kZIP64_EXTENDED_MAGIC = 0x0001, ///< Zip64 Extended Information Extra Field
50  kZIP_MAGIC_LEN = 4, ///< Length of magic's
51  kMAX_VAR_LEN = 0xffff, ///< Max variable-width field length
52  kMAX_SIZE = 0xffffffff, ///< Max size of things
53 
54  // - Offsets into the central directory headers
72 
73  // - Offsets into the Zip64 end of central directory record (EDR)
85 
86  // - Offsets into the Zip64 end of central directory locator (EDL)
92 
93  // - Offsets into the end-of-archive header
103 
104  // - Offsets into the local entry headers
116 
117  // - Offsets into the Zip64 Extended Information Extra Field
125 
126  // - Compression method and strategy
127  kSTORED = 0, ///< Stored as is
128  kDEFLATED = 8 ///< Stored using deflate
129  };
130 
131  TZIPFile(const TZIPFile&); // Not implemented
132  TZIPFile& operator=(const TZIPFile&); // Not implemented
133 
134 public:
135  TZIPFile();
136  TZIPFile(const char *archive, const char *member, TFile *file);
137  virtual ~TZIPFile() { }
138 
139  virtual Int_t OpenArchive();
140  virtual Int_t SetCurrentMember();
141 
142  void Print(Option_t *option = "") const;
143 
144  ClassDef(TZIPFile,1) //A ZIP archive file
145 };
146 
147 /**
148 \class TZIPMember
149 \ingroup IO
150 A ZIP archive consists of files compressed with the popular ZLIB
151 compression algorithm; this class records the information about a
152 single archive member.
153 */
154 
155 
156 class TZIPMember : public TArchiveMember {
157 
158 friend class TZIPFile;
159 
160 private:
161  void *fLocal; ///< Extra file header data
162  UInt_t fLocalLen; ///< Length of extra file header data
163  void *fGlobal; ///< Extra directory data
164  UInt_t fGlobalLen; ///< Length of extra directory data
165  UInt_t fCRC32; ///< CRC-32 for all decompressed data
166  UInt_t fAttrInt; ///< Internal file attributes
167  UInt_t fAttrExt; ///< External file attributes
168  UInt_t fMethod; ///< Compression type
169  UInt_t fLevel; ///< Compression level
170 
171 public:
172  TZIPMember();
173  TZIPMember(const char *name);
174  TZIPMember(const TZIPMember &member);
175  TZIPMember &operator=(const TZIPMember &rhs);
176  virtual ~TZIPMember();
177 
178  void *GetLocal() const { return fLocal; }
179  UInt_t GetLocalLen() const { return fLocalLen; }
180  void *GetGlobal() const { return fGlobal; }
181  UInt_t GetGlobalLen() const { return fGlobalLen; }
182  UInt_t GetCRC32() const { return fCRC32; }
183  UInt_t GetAttrInt() const { return fAttrInt; }
184  UInt_t GetAttrExt() const { return fAttrExt; }
185  UInt_t GetMethod() const { return fMethod; }
186  UInt_t GetLevel() const { return fLevel; }
187 
188  void Print(Option_t *option = "") const;
189 
190  ClassDef(TZIPMember, 0); //A ZIP archive member file
191 };
192 
193 #endif
Stored using deflate.
Definition: TZIPFile.h:128
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive...
Definition: TArchiveFile.h:24
Int_t ReadZip64EndRecord(Long64_t pos)
Read Zip64 end of central directory record.
Definition: TZIPFile.cxx:246
virtual Int_t SetCurrentMember()
Find the desired member in the member array and make it the current member.
Definition: TZIPFile.cxx:486
long long Long64_t
Definition: RtypesCore.h:69
auto * m
Definition: textangle.C:8
Long64_t fDirSize
Central directory size.
Definition: TZIPFile.h:24
virtual Int_t OpenArchive()
Open archive and read end-header and directory.
Definition: TZIPFile.cxx:88
void * fLocal
Extra file header data.
Definition: TZIPFile.h:161
Stored as is.
Definition: TZIPFile.h:127
const char Option_t
Definition: RtypesCore.h:62
Max variable-width field length.
Definition: TZIPFile.h:51
Int_t ReadMemberHeader(TZIPMember *member)
Read the member header of the ZIP archive.
Definition: TZIPFile.cxx:404
Long64_t FindEndHeader()
Find the end header of the ZIP archive. Returns 0 in case of error.
Definition: TZIPFile.cxx:98
UInt_t Get(const void *buffer, Int_t bytes)
Read a "bytes" long little-endian integer value from "buffer".
Definition: TZIPFile.cxx:514
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:47
Int_t ReadEndHeader(Long64_t pos)
Read the end header of the ZIP archive including the archive comment at the current file position...
Definition: TZIPFile.cxx:139
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
UInt_t GetLocalLen() const
Definition: TZIPFile.h:179
Length of magic&#39;s.
Definition: TZIPFile.h:50
TString fComment
Archive comment.
Definition: TZIPFile.h:26
ULong64_t Get64(const void *buffer, Int_t bytes)
Read a 8 byte long little-endian integer value from "buffer".
Definition: TZIPFile.cxx:535
TZIPFile()
Default ctor.
Definition: TZIPFile.cxx:65
Long64_t fDirPos
Central directory position.
Definition: TZIPFile.h:23
Zip64 Extended Information Extra Field.
Definition: TZIPFile.h:49
#define ClassDef(name, id)
Definition: Rtypes.h:320
Describes a ZIP archive file containing multiple sub-files.
Definition: TZIPFile.h:20
UInt_t GetAttrExt() const
Definition: TZIPFile.h:184
Long64_t ReadZip64EndLocator(Long64_t pos)
Read Zip64 end of central directory locator.
Definition: TZIPFile.cxx:211
EZIPConstants
ZIP archive constants.
Definition: TZIPFile.h:39
UInt_t GetLevel() const
Definition: TZIPFile.h:186
void Print(Option_t *option="") const
Pretty print ZIP archive members.
Definition: TZIPFile.cxx:557
Max size of things.
Definition: TZIPFile.h:52
UInt_t GetCRC32() const
Definition: TZIPFile.h:182
UInt_t fGlobalLen
Length of extra directory data.
Definition: TZIPFile.h:164
Int_t ReadDirectory()
Read the directory of the ZIP archive.
Definition: TZIPFile.cxx:278
unsigned int UInt_t
Definition: RtypesCore.h:42
UInt_t GetMethod() const
Definition: TZIPFile.h:185
UInt_t fMethod
Compression type.
Definition: TZIPFile.h:168
Long64_t fDirOffset
Central directory offset (from the beginning of the archive)
Definition: TZIPFile.h:25
UInt_t fAttrExt
External file attributes.
Definition: TZIPFile.h:167
void * GetGlobal() const
Definition: TZIPFile.h:180
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual ~TZIPFile()
Definition: TZIPFile.h:137
Definition: file.py:1
Int_t DecodeZip64ExtendedExtraField(TZIPMember *m, Bool_t global=kTRUE)
Decode the Zip64 extended extra field.
Definition: TZIPFile.cxx:441
UInt_t GetAttrInt() const
Definition: TZIPFile.h:183
void * GetLocal() const
Definition: TZIPFile.h:178
UInt_t fLocalLen
Length of extra file header data.
Definition: TZIPFile.h:162
UInt_t fLevel
Compression level.
Definition: TZIPFile.h:169
void * fGlobal
Extra directory data.
Definition: TZIPFile.h:163
A ZIP archive consists of files compressed with the popular ZLIB compression algorithm; this class re...
Definition: TZIPFile.h:156
TZIPFile & operator=(const TZIPFile &)
const Bool_t kTRUE
Definition: RtypesCore.h:87
UInt_t fAttrInt
Internal file attributes.
Definition: TZIPFile.h:166
char name[80]
Definition: TGX11.cxx:109
UInt_t GetGlobalLen() const
Definition: TZIPFile.h:181
UInt_t fCRC32
CRC-32 for all decompressed data.
Definition: TZIPFile.h:165