Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TZIPFile.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Fons Rademakers and Lassi Tuura 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/**
13\class TZIPFile
14\ingroup IO
15
16Describes a ZIP archive file containing multiple sub-files.
17
18Typically the sub-files are ROOT files. Notice that
19the ROOT files should not be compressed when being added to the
20ZIP file, since ROOT files are normally already compressed.
21Such a ZIP file should be created like:
22 zip -n root multi file1.root file2.root
23which creates a ZIP file multi.zip.
24A ZIP archive consists of files compressed with the popular ZLIB
25compression algorithm. The archive format is used among others by
26PKZip and Info-ZIP. The compression algorithm is also used by
27GZIP and the PNG graphics standard. The format of the archives is
28explained briefly below. This class provides an interface to read
29such archives.
30A ZIP archive contains a prefix, series of archive members
31(sub-files), and a central directory. In theory the archive could
32span multiple disks (or files) with the central directory of the
33whole archive on the last disk, but this class does not support
34such multi-part archives. The prefix is only used in self-extracting
35executable archive files.
36The members are stored in the archive sequentially, each with a
37local header followed by the (optionally) compressed data; the local
38header describes the member, including its file name and compressed
39and real sizes. The central directory includes the member details
40again, plus allows an extra member comment to be added. The last
41member in the central directory is an end marker that can contain
42a comment for the whole archive. Both the local header and the
43central directory can also carry extra member-specific data; the
44data in the local and global parts can be different.
45The fact that the archive has a global directory makes it efficient
46and allows for only the reading of the desired data, one does not
47have to scan through the whole file to find the desired sub-file.
48The Zip64 extensions are supported so files larger than 2GB can be
49stored in archives larger than 4 GB.
50Once the archive has been opened, the client can query the members
51and read their contents by asking the archive for an offset where
52the sub-file starts. The members can be accessed in any order.
53*/
54
55#include "TZIPFile.h"
56#include "TFile.h"
57#include "TObjArray.h"
58
59
60
61////////////////////////////////////////////////////////////////////////////////
62/// Default ctor.
63
65{
66 fDirPos = 0;
67 fDirSize = 0;
68 fDirOffset = 0;
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Specify the archive name and member name. The member can be a decimal
73/// number which allows to access the n-th member.
74
75TZIPFile::TZIPFile(const char *archive, const char *member, TFile *file)
77{
78 fDirPos = 0;
79 fDirSize = 0;
80 fDirOffset = 0;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Open archive and read end-header and directory. Returns -1 in case
85/// of error, 0 otherwise.
86
88{
89 if (ReadEndHeader(FindEndHeader()) == -1)
90 return -1;
91 return ReadDirectory();
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Find the end header of the ZIP archive. Returns 0 in case of error.
96
98{
99 const Int_t kBUFSIZE = 1024;
101 Long64_t limit = std::min(size, Long64_t(kMAX_VAR_LEN));
102 char buf[kBUFSIZE+4];
103
104 // Note, this works correctly even if the signature straddles read
105 // boundaries since we always read an overlapped area of four
106 // bytes on the next read
107 for (Long64_t offset = 4; offset < limit; ) {
108 offset = std::min(offset + kBUFSIZE, limit);
109
110 Long64_t pos = size - offset;
111 Int_t n = std::min(kBUFSIZE+4, Int_t(offset));
112
113 fFile->Seek(pos);
114 if (fFile->ReadBuffer(buf, n)) {
115 Error("FindEndHeader", "error reading %d bytes at %lld", n, pos);
116 return 0;
117 }
118
119 for (Int_t i = n - 4; i > 0; i--)
120 if (buf[i] == 0x50 && buf[i+1] == 0x4b &&
121 buf[i+2] == 0x05 && buf[i+3] == 0x06) {
122 return pos + i;
123 }
124 }
125
126 Error("FindEndHeader", "did not find end header in %s", fArchiveName.Data());
127
128 return 0;
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Read the end header of the ZIP archive including the archive comment
133/// at the current file position. Check that it really was a single-disk
134/// archive with all the entries as expected. Most importantly, figure
135/// out where the central directory begins. Returns -1 in case of error,
136/// 0 otherwise.
137
139{
140 char buf[kEND_HEADER_SIZE];
141
142 // read and validate first the end header magic
143 fFile->Seek(pos);
144 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
146 Error("ReadEndHeader", "wrong end header magic in %s", fArchiveName.Data());
147 return -1;
148 }
149
150 // read rest of the header
152 Error("ReadEndHeader", "error reading %d end header bytes from %s",
154 return -1;
155 }
156
164
165 if (disk != 0 || dirdisk != 0) {
166 Error("ReadHeader", "only single disk archives are supported in %s",
168 return -1;
169 }
170 if (dhdrs != thdrs) {
171 Error("ReadEndHeader", "inconsistency in end header data in %s",
173 return -1;
174 }
175
176 char *comment = new char[commlen+1];
177 if (fFile->ReadBuffer(comment, commlen)) {
178 Error("ReadEndHeader", "error reading %d end header comment bytes from %s",
180 delete [] comment;
181 return -1;
182 }
183 comment[commlen] = '\0';
184
185 fComment = comment;
187 fDirSize = dirsz;
188
189 delete [] comment;
190
191 // Try to read Zip64 end of central directory locator
193 if (recoff < 0) {
194 if (recoff == -1)
195 return -1;
196 return 0;
197 }
198
199 if (ReadZip64EndRecord(recoff) < 0)
200 return -1;
201
202 return 0;
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Read Zip64 end of central directory locator. Returns -1 in case of error,
207/// -2 in case end locator magic is not found (i.e. not a zip64 file) and
208/// offset of Zip64 end of central directory record in case of success.
209
211{
212 char buf[kZIP64_EDL_HEADER_SIZE];
213
214 // read and validate first the end header magic
215 fFile->Seek(pos);
216 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
218 return -2;
219 }
220
221 // read rest of the header
223 Error("ReadZip64EndLocator", "error reading %d Zip64 end locator header bytes from %s",
225 return -1;
226 }
227
231
232 if (dirdisk != 0 || totdisk != 1) {
233 Error("ReadZip64EndLocator", "only single disk archives are supported in %s",
235 return -1;
236 }
237
238 return recoff;
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Read Zip64 end of central directory record. Returns -1 in case of error
243/// and 0 in case of success.
244
246{
247 char buf[kZIP64_EDR_HEADER_SIZE];
248
249 // read and validate first the end header magic
250 fFile->Seek(pos);
251 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
253 Error("ReadZip64EndRecord", "no Zip64 end of directory record\n");
254 return -1;
255 }
256
257 // read rest of the header
259 Error("ReadZip64EndRecord", "error reading %d Zip64 end record header bytes from %s",
261 return -1;
262 }
263
266
268 fDirSize = dirsz;
269
270 return 0;
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Read the directory of the ZIP archive. Returns -1 in case of error,
275/// 0 otherwise.
276
278{
279 char buf[kDIR_HEADER_SIZE];
280 UInt_t n;
281
282 // read and validate first the header magic
284 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
285 (n = Get(buf, kZIP_MAGIC_LEN)) != kDIR_HEADER_MAGIC) {
286 Error("ReadDirectory", "wrong directory header magic in %s",
288 return -1;
289 }
290
291 // now read the full directory
292 while (n == kDIR_HEADER_MAGIC) {
293 // read the rest of the header
295 Error("ReadDirectory", "error reading %d directory bytes from %s",
297 return -1;
298 }
299
301 UInt_t flags = Get(buf + kDIR_FLAG_OFF, kDIR_FLAG_LEN);
303 UInt_t time = Get(buf + kDIR_DATE_OFF, kDIR_DATE_LEN);
307 Int_t namelen = Get(buf + kDIR_NAMELEN_OFF, kDIR_NAMELEN_LEN);
314
315 // check value sanity and the variable-length fields
318 flags & 8 ||
319 (method != kSTORED && method != kDEFLATED) ||
320 disk != 0 ||
321 csize < 0 ||
322 usize < 0 ||
323 csize > kMaxUInt ||
324 usize > kMaxUInt) {
325 Error("ReadDirectory", "inconsistency in directory data in %s",
327 return -1;
328 }
329
330 char *name = new char[namelen+1];
331 char *extra = new char[extlen];
332 char *comment = new char[commlen+1];
333 if (fFile->ReadBuffer(name, namelen) ||
334 fFile->ReadBuffer(extra, extlen) ||
335 fFile->ReadBuffer(comment, commlen)) {
336 Error("ReadDirectory", "error reading additional directory data from %s",
338 delete [] name;
339 delete [] extra;
340 delete [] comment;
341 return -1;
342 }
343 name[namelen] = '\0';
344 comment[commlen] = '\0';
345
346 // create a new archive member and store the fields
347 TZIPMember *m = new TZIPMember(name);
348 fMembers->Add(m);
349
350 m->fMethod = method;
351 m->fLevel = method == kSTORED ? 0
352 : (flags & 6)/2 == 0 ? 3 // default (:N)
353 : (flags & 6)/2 == 1 ? 9 // best (:X)
354 : (flags & 6)/2 == 2 ? 2 // fast (:F)
355 : (flags & 6)/2 == 3 ? 1 // fastest (:F)
356 : 3; // unreached
357 m->fCsize = csize;
358 m->fDsize = usize;
359 m->fCRC32 = crc32;
360 m->fModTime.Set(time, kTRUE); // DOS date/time format
361 m->fGlobalLen = extlen;
362 m->fGlobal = extra;
363 m->fComment = comment;
364 m->fAttrInt = iattr;
365 m->fAttrExt = xattr;
366 m->fPosition = offset;
367
368 delete [] name;
369 delete [] comment;
370 // extra is adopted be the TZIPMember
371
373 return -1;
374
375 if (gDebug)
376 Info("ReadDirectory", "%lld %lld %s %s",
377 m->GetDecompressedSize(), m->GetCompressedSize(),
378 m->GetModTime().AsSQLString(), m->GetName());
379
380 // done, read the next magic
381 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN)) {
382 Error("ReadDirectory", "error reading %d directory bytes from %s",
384 return -1;
385 }
386 n = Get(buf, kZIP_MAGIC_LEN);
387 }
388
389 // should now see end of archive
391 Error("ReadDirectory", "wrong end header magic in %s", fArchiveName.Data());
392 return -1;
393 }
394
395 return 0;
396}
397
398////////////////////////////////////////////////////////////////////////////////
399/// Read the member header of the ZIP archive. Sets the position where
400/// the data starts in the member object. Returns -1 in case of error,
401/// 0 otherwise.
402
404{
405 // read file header to find start of data, since extra len might be
406 // different we cannot take it from the directory data
407 char buf[kENTRY_HEADER_SIZE];
408
409 // read and validate first the entry header magic
410 fFile->Seek(member->fPosition);
411 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
413 Error("ReadMemberHeader", "wrong entry header magic in %s",
415 return -1;
416 }
417
418 // read rest of the header
420 Error("ReadMemberHeader", "error reading %d member header bytes from %s",
422 return -1;
423 }
426
427 member->fFilePosition = member->fPosition + kENTRY_HEADER_SIZE +
428 namelen + extlen;
429
430 return 0;
431}
432
433////////////////////////////////////////////////////////////////////////////////
434/// Decode the Zip64 extended extra field. If global is true, decode the
435/// extra field coming from the central directory, if false decode the
436/// extra field coming from the local file header. Returns -1 in case of
437/// error, -2 in case Zip64 extra block was not found and 0 in case of
438/// success.
439
441{
442 char *buf;
443 Int_t len;
444 Int_t ret = -2;
445
446 if (global) {
447 buf = (char *) m->fGlobal;
448 len = m->fGlobalLen;
449 } else {
450 buf = (char *) m->fLocal;
451 len = m->fLocalLen;
452 }
453
454 if (!buf || !len) {
455 return ret;
456 }
457
458 Int_t off = 0;
459 while (len > 0) {
462 if (tag == kZIP64_EXTENDED_MAGIC) {
463 // The Zip64 extended entry field may contain the following values:
464 // - Original uncompressed size (8 B)
465 // - Size of compressed data (8 B)
466 // - Offset of local header record (8 B)
467 // These are all optional and only appear if the respective non-extra field is set to kMAX_SIZE (0xFFFF'FFFF).
468 // However they must appear in the above order.
470 if (m->fDsize == kMAX_SIZE && size >= kZIP64_EXTENDED_USIZE_LEN) {
471 m->fDsize = Get64(buf + off + relOff, kZIP64_EXTENDED_USIZE_LEN);
474 }
475 if (m->fCsize == kMAX_SIZE && size >= kZIP64_EXTENDED_CSIZE_LEN) {
476 m->fCsize = Get64(buf + off + relOff, kZIP64_EXTENDED_CSIZE_LEN);
479 }
480 if (m->fPosition == kMAX_SIZE && size >= kZIP64_EXTENDED_HDR_OFFSET_LEN) {
481 m->fPosition = Get64(buf + off + relOff, kZIP64_EXTENDED_HDR_OFFSET_LEN);
482 }
483
484 ret = 0;
485 }
488 }
489
490 return ret;
491}
492
493////////////////////////////////////////////////////////////////////////////////
494/// Find the desired member in the member array and make it the
495/// current member. Returns -1 in case member is not found, 0 otherwise.
496
498{
499 fCurMember = 0;
500
501 if (fMemberIndex > -1) {
503 if (!fCurMember)
504 return -1;
506 } else {
507 for (int i = 0; i < fMembers->GetEntriesFast(); i++) {
508 TZIPMember *m = (TZIPMember *) fMembers->At(i);
509 if (fMemberName == m->fName) {
510 fCurMember = m;
511 fMemberIndex = i;
512 break;
513 }
514 }
515 if (!fCurMember)
516 return -1;
517 }
518
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Read a "bytes" long little-endian integer value from "buffer".
524
525UInt_t TZIPFile::Get(const void *buffer, Int_t bytes)
526{
527 UInt_t value = 0;
528
529 if (bytes > 4) {
530 Error("Get", "can not read > 4 byte integers, use Get64");
531 return value;
532 }
533#ifdef R__BYTESWAP
534 memcpy(&value, buffer, bytes);
535#else
536 const UChar_t *buf = static_cast<const unsigned char *>(buffer);
537 for (UInt_t shift = 0; bytes; shift += 8, --bytes, ++buf)
538 value += *buf << shift;
539#endif
540 return value;
541}
542
543////////////////////////////////////////////////////////////////////////////////
544/// Read a 8 byte long little-endian integer value from "buffer".
545
547{
548 ULong64_t value = 0;
549
550 if (bytes != 8) {
551 Error("Get64", "bytes must be 8 (asked for %d)", bytes);
552 return value;
553 }
554
555#ifdef R__BYTESWAP
556 memcpy(&value, buffer, bytes);
557#else
558 const UChar_t *buf = static_cast<const unsigned char *>(buffer);
559 for (UInt_t shift = 0; bytes; shift += 8, --bytes, ++buf)
560 value += *buf << shift;
561#endif
562 return value;
563}
564
565////////////////////////////////////////////////////////////////////////////////
566/// Pretty print ZIP archive members.
567
569{
570 if (fMembers)
571 fMembers->Print();
572}
573
574
575
576////////////////////////////////////////////////////////////////////////////////
577/// Default ctor.
578
580{
581 fLocal = 0;
582 fLocalLen = 0;
583 fGlobal = 0;
584 fGlobalLen = 0;
585 fCRC32 = 0;
586 fAttrInt = 0;
587 fAttrExt = 0;
588 fMethod = 0;
589 fLevel = 0;
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Create ZIP member file.
594
597{
598 fLocal = 0;
599 fLocalLen = 0;
600 fGlobal = 0;
601 fGlobalLen = 0;
602 fCRC32 = 0;
603 fAttrInt = 0;
604 fAttrExt = 0;
605 fMethod = 0;
606 fLevel = 0;
607}
608
609////////////////////////////////////////////////////////////////////////////////
610/// Copy ctor.
611
614{
615 fLocal = 0;
616 fLocalLen = member.fLocalLen;
617 fGlobal = 0;
618 fGlobalLen = member.fGlobalLen;
619 fCRC32 = member.fCRC32;
620 fAttrInt = member.fAttrInt;
621 fAttrExt = member.fAttrExt;
622 fMethod = member.fMethod;
623 fLevel = member.fLevel;
624
625 if (member.fLocal) {
626 fLocal = new char [fLocalLen];
627 memcpy(fLocal, member.fLocal, fLocalLen);
628 }
629 if (member.fGlobal) {
630 fGlobal = new char [fGlobalLen];
631 memcpy(fGlobal, member.fGlobal, fGlobalLen);
632 }
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Assignment operator.
637
639{
640 if (this != &rhs) {
642
643 delete [] (char*) fLocal;
644 delete [] (char*) fGlobal;
645
646 fLocal = 0;
647 fLocalLen = rhs.fLocalLen;
648 fGlobal = 0;
649 fGlobalLen = rhs.fGlobalLen;
650 fCRC32 = rhs.fCRC32;
651 fAttrInt = rhs.fAttrInt;
652 fAttrExt = rhs.fAttrExt;
653 fMethod = rhs.fMethod;
654 fLevel = rhs.fLevel;
655
656 if (rhs.fLocal) {
657 fLocal = new char [fLocalLen];
658 memcpy(fLocal, rhs.fLocal, fLocalLen);
659 }
660 if (rhs.fGlobal) {
661 fGlobal = new char [fGlobalLen];
662 memcpy(fGlobal, rhs.fGlobal, fGlobalLen);
663 }
664 }
665 return *this;
666}
667
668////////////////////////////////////////////////////////////////////////////////
669/// Cleanup.
670
672{
673 delete [] (char*) fLocal;
674 delete [] (char*) fGlobal;
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// Pretty print basic ZIP member info.
679
681{
682 printf("%-20lld", fDsize);
683 printf(" %s %s\n", fModTime.AsSQLString(), fName.Data());
684}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr UInt_t kMaxUInt
Definition RtypesCore.h:118
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
char name[80]
Definition TGX11.cxx:110
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive.
TArchiveMember * fCurMember
Current archive member.
TString fMemberName
Sub-file name.
TString fArchiveName
Archive file name.
Int_t fMemberIndex
Index of sub-file in archive.
TObjArray * fMembers
Members in this archive.
TFile * fFile
File stream used to access the archive.
TDatime fModTime
Modification time.
TArchiveMember & operator=(const TArchiveMember &rhs)
Assignment operator.
TString fName
Name of member.
const char * GetName() const override
Returns name of object.
Long64_t fDsize
Decompressed size.
void Print(Option_t *option="") const override
Default print for collections, calls Print(option, 1).
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
Definition TDatime.cxx:151
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
Definition TFile.cxx:2304
virtual Long64_t GetSize() const
Returns the current file size.
Definition TFile.cxx:1336
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition TFile.cxx:1800
Int_t GetEntriesFast() const
Definition TObjArray.h:58
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
void Add(TObject *obj) override
Definition TObjArray.h:68
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1045
const char * Data() const
Definition TString.h:384
Long64_t fDirPos
Central directory position.
Definition TZIPFile.h:23
Int_t ReadMemberHeader(TZIPMember *member)
Read the member header of the ZIP archive.
Definition TZIPFile.cxx:403
void Print(Option_t *option="") const override
Pretty print ZIP archive members.
Definition TZIPFile.cxx:568
Int_t DecodeZip64ExtendedExtraField(TZIPMember *m, Bool_t global=kTRUE)
Decode the Zip64 extended extra field.
Definition TZIPFile.cxx:440
Long64_t ReadZip64EndLocator(Long64_t pos)
Read Zip64 end of central directory locator.
Definition TZIPFile.cxx:210
Long64_t fDirSize
Central directory size.
Definition TZIPFile.h:24
Int_t ReadZip64EndRecord(Long64_t pos)
Read Zip64 end of central directory record.
Definition TZIPFile.cxx:245
UInt_t Get(const void *buffer, Int_t bytes)
Read a "bytes" long little-endian integer value from "buffer".
Definition TZIPFile.cxx:525
Int_t ReadDirectory()
Read the directory of the ZIP archive.
Definition TZIPFile.cxx:277
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:138
Int_t SetCurrentMember() override
Find the desired member in the member array and make it the current member.
Definition TZIPFile.cxx:497
ULong64_t Get64(const void *buffer, Int_t bytes)
Read a 8 byte long little-endian integer value from "buffer".
Definition TZIPFile.cxx:546
Long64_t FindEndHeader()
Find the end header of the ZIP archive. Returns 0 in case of error.
Definition TZIPFile.cxx:97
Long64_t fDirOffset
Central directory offset (from the beginning of the archive)
Definition TZIPFile.h:25
TString fComment
Archive comment.
Definition TZIPFile.h:26
Int_t OpenArchive() override
Open archive and read end-header and directory.
Definition TZIPFile.cxx:87
@ kZIP64_EXTENDED_MAGIC_OFF
Definition TZIPFile.h:118
@ kZIP64_EDR_DIR_SIZE_LEN
Definition TZIPFile.h:82
@ kZIP64_EDL_DISK_LEN
Definition TZIPFile.h:88
@ kZIP64_EXTENDED_USIZE_OFF
Definition TZIPFile.h:120
@ kEND_HEADER_SIZE
Definition TZIPFile.h:102
@ kDIR_DATE_OFF
Definition TZIPFile.h:60
@ kARCHIVE_VERSION
Definition TZIPFile.h:41
@ kZIP64_EXTENDED_CSIZE_LEN
Definition TZIPFile.h:121
@ kZIP64_EDR_DIR_SIZE_OFF
Definition TZIPFile.h:82
@ kDIR_CSIZE_OFF
Definition TZIPFile.h:62
@ kDIR_HEADER_MAGIC
Definition TZIPFile.h:44
@ kEND_DIR_OFFSET_OFF
Definition TZIPFile.h:100
@ kEND_DIR_OFFSET_LEN
Definition TZIPFile.h:100
@ kDIR_CRC32_LEN
Definition TZIPFile.h:61
@ kZIP64_EXTENDED_USIZE_LEN
Definition TZIPFile.h:120
@ kEND_DISK_LEN
Definition TZIPFile.h:95
@ kZIP64_EDL_TOTAL_DISK_OFF
Definition TZIPFile.h:90
@ kMAX_SIZE
Max size of things.
Definition TZIPFile.h:52
@ kZIP64_EDL_REC_OFFSET_OFF
Definition TZIPFile.h:89
@ kDIR_INT_ATTR_OFF
Definition TZIPFile.h:68
@ kENTRY_NAMELEN_OFF
Definition TZIPFile.h:113
@ kDEFLATED
Stored using deflate.
Definition TZIPFile.h:128
@ kEND_COMMENTLEN_LEN
Definition TZIPFile.h:101
@ kDIR_DISK_START_LEN
Definition TZIPFile.h:67
@ kDIR_NAMELEN_LEN
Definition TZIPFile.h:64
@ kDIR_ENTRY_POS_OFF
Definition TZIPFile.h:70
@ kDIR_COMMENTLEN_OFF
Definition TZIPFile.h:66
@ kZIP64_EXTENDED_HDR_OFFSET_LEN
Definition TZIPFile.h:122
@ kEND_DISK_HDRS_OFF
Definition TZIPFile.h:97
@ kZIP64_EXTENDED_SIZE_LEN
Definition TZIPFile.h:119
@ kSTORED
Stored as is.
Definition TZIPFile.h:127
@ kEND_DIR_DISK_OFF
Definition TZIPFile.h:96
@ kDIR_CSIZE_LEN
Definition TZIPFile.h:62
@ kDIR_INT_ATTR_LEN
Definition TZIPFile.h:68
@ kDIR_VREQD_LEN
Definition TZIPFile.h:57
@ kDIR_EXT_ATTR_LEN
Definition TZIPFile.h:69
@ kZIP64_EXTENDED_MAGIC
Zip64 Extended Information Extra Field.
Definition TZIPFile.h:49
@ kZIP64_EDL_REC_OFFSET_LEN
Definition TZIPFile.h:89
@ kEND_COMMENTLEN_OFF
Definition TZIPFile.h:101
@ kZIP64_EDR_HEADER_SIZE
Definition TZIPFile.h:84
@ kENTRY_EXTRALEN_OFF
Definition TZIPFile.h:114
@ kZIP64_EDL_TOTAL_DISK_LEN
Definition TZIPFile.h:90
@ kZIP64_EDR_DIR_OFFSET_OFF
Definition TZIPFile.h:83
@ kEND_DISK_HDRS_LEN
Definition TZIPFile.h:97
@ kZIP64_EDR_HEADER_MAGIC
Definition TZIPFile.h:47
@ kZIP64_EDL_HEADER_SIZE
Definition TZIPFile.h:91
@ kZIP64_EDR_DIR_OFFSET_LEN
Definition TZIPFile.h:83
@ kMAX_VAR_LEN
Max variable-width field length.
Definition TZIPFile.h:51
@ kDIR_HEADER_SIZE
Definition TZIPFile.h:71
@ kDIR_ENTRY_POS_LEN
Definition TZIPFile.h:70
@ kZIP64_EDL_HEADER_MAGIC
Definition TZIPFile.h:48
@ kENTRY_HEADER_MAGIC
Definition TZIPFile.h:45
@ kDIR_DATE_LEN
Definition TZIPFile.h:60
@ kDIR_METHOD_LEN
Definition TZIPFile.h:59
@ kDIR_EXTRALEN_OFF
Definition TZIPFile.h:65
@ kDIR_CRC32_OFF
Definition TZIPFile.h:61
@ kEND_TOTAL_HDRS_LEN
Definition TZIPFile.h:98
@ kDIR_EXT_ATTR_OFF
Definition TZIPFile.h:69
@ kENTRY_NAMELEN_LEN
Definition TZIPFile.h:113
@ kZIP64_EXTENDED_SIZE_OFF
Definition TZIPFile.h:119
@ kEND_DISK_OFF
Definition TZIPFile.h:95
@ kZIP64_EDL_DISK_OFF
Definition TZIPFile.h:88
@ kENTRY_HEADER_SIZE
Definition TZIPFile.h:115
@ kZIP_MAGIC_LEN
Length of magic's.
Definition TZIPFile.h:50
@ kEND_HEADER_MAGIC
Definition TZIPFile.h:46
@ kDIR_COMMENTLEN_LEN
Definition TZIPFile.h:66
@ kDIR_VREQD_OFF
Definition TZIPFile.h:57
@ kEND_DIR_SIZE_OFF
Definition TZIPFile.h:99
@ kZIP64_EXTENDED_MAGIC_LEN
Definition TZIPFile.h:118
@ kEND_TOTAL_HDRS_OFF
Definition TZIPFile.h:98
@ kEND_DIR_SIZE_LEN
Definition TZIPFile.h:99
@ kDIR_FLAG_LEN
Definition TZIPFile.h:58
@ kDIR_DISK_START_OFF
Definition TZIPFile.h:67
@ kEND_DIR_DISK_LEN
Definition TZIPFile.h:96
@ kDIR_NAMELEN_OFF
Definition TZIPFile.h:64
@ kDIR_USIZE_LEN
Definition TZIPFile.h:63
@ kDIR_MAGIC_OFF
Definition TZIPFile.h:55
@ kENTRY_EXTRALEN_LEN
Definition TZIPFile.h:114
@ kDIR_EXTRALEN_LEN
Definition TZIPFile.h:65
@ kDIR_FLAG_OFF
Definition TZIPFile.h:58
@ kDIR_USIZE_OFF
Definition TZIPFile.h:63
@ kDIR_METHOD_OFF
Definition TZIPFile.h:59
TZIPFile()
Default ctor.
Definition TZIPFile.cxx:64
A ZIP archive consists of files compressed with the popular ZLIB compression algorithm; this class re...
Definition TZIPFile.h:156
UInt_t fLevel
Compression level.
Definition TZIPFile.h:169
UInt_t fGlobalLen
Length of extra directory data.
Definition TZIPFile.h:164
UInt_t fCRC32
CRC-32 for all decompressed data.
Definition TZIPFile.h:165
UInt_t fAttrInt
Internal file attributes.
Definition TZIPFile.h:166
UInt_t fLocalLen
Length of extra file header data.
Definition TZIPFile.h:162
TZIPMember()
Default ctor.
Definition TZIPFile.cxx:579
UInt_t fMethod
Compression type.
Definition TZIPFile.h:168
void Print(Option_t *option="") const override
Pretty print basic ZIP member info.
Definition TZIPFile.cxx:680
~TZIPMember() override
Cleanup.
Definition TZIPFile.cxx:671
UInt_t fAttrExt
External file attributes.
Definition TZIPFile.h:167
TZIPMember & operator=(const TZIPMember &rhs)
Assignment operator.
Definition TZIPFile.cxx:638
void * fGlobal
Extra directory data.
Definition TZIPFile.h:163
void * fLocal
Extra file header data.
Definition TZIPFile.h:161
const Int_t n
Definition legend1.C:16
TMarker m
Definition textangle.C:8