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
61
62////////////////////////////////////////////////////////////////////////////////
63/// Default ctor.
64
66{
67 fDirPos = 0;
68 fDirSize = 0;
69 fDirOffset = 0;
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Specify the archive name and member name. The member can be a decimal
74/// number which allows to access the n-th member.
75
76TZIPFile::TZIPFile(const char *archive, const char *member, TFile *file)
78{
79 fDirPos = 0;
80 fDirSize = 0;
81 fDirOffset = 0;
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Open archive and read end-header and directory. Returns -1 in case
86/// of error, 0 otherwise.
87
89{
90 if (ReadEndHeader(FindEndHeader()) == -1)
91 return -1;
92 return ReadDirectory();
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Find the end header of the ZIP archive. Returns 0 in case of error.
97
99{
100 const Int_t kBUFSIZE = 1024;
103 char buf[kBUFSIZE+4];
104
105 // Note, this works correctly even if the signature straddles read
106 // boundaries since we always read an overlapped area of four
107 // bytes on the next read
108 for (Long64_t offset = 4; offset < limit; ) {
109 offset = TMath::Min(offset + kBUFSIZE, limit);
110
111 Long64_t pos = size - offset;
113
114 fFile->Seek(pos);
115 if (fFile->ReadBuffer(buf, n)) {
116 Error("FindEndHeader", "error reading %d bytes at %lld", n, pos);
117 return 0;
118 }
119
120 for (Int_t i = n - 4; i > 0; i--)
121 if (buf[i] == 0x50 && buf[i+1] == 0x4b &&
122 buf[i+2] == 0x05 && buf[i+3] == 0x06) {
123 return pos + i;
124 }
125 }
126
127 Error("FindEndHeader", "did not find end header in %s", fArchiveName.Data());
128
129 return 0;
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Read the end header of the ZIP archive including the archive comment
134/// at the current file position. Check that it really was a single-disk
135/// archive with all the entries as expected. Most importantly, figure
136/// out where the central directory begins. Returns -1 in case of error,
137/// 0 otherwise.
138
140{
141 char buf[kEND_HEADER_SIZE];
142
143 // read and validate first the end header magic
144 fFile->Seek(pos);
145 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
147 Error("ReadEndHeader", "wrong end header magic in %s", fArchiveName.Data());
148 return -1;
149 }
150
151 // read rest of the header
153 Error("ReadEndHeader", "error reading %d end header bytes from %s",
155 return -1;
156 }
157
165
166 if (disk != 0 || dirdisk != 0) {
167 Error("ReadHeader", "only single disk archives are supported in %s",
169 return -1;
170 }
171 if (dhdrs != thdrs) {
172 Error("ReadEndHeader", "inconsistency in end header data in %s",
174 return -1;
175 }
176
177 char *comment = new char[commlen+1];
178 if (fFile->ReadBuffer(comment, commlen)) {
179 Error("ReadEndHeader", "error reading %d end header comment bytes from %s",
181 delete [] comment;
182 return -1;
183 }
184 comment[commlen] = '\0';
185
186 fComment = comment;
188 fDirSize = dirsz;
189
190 delete [] comment;
191
192 // Try to read Zip64 end of central directory locator
194 if (recoff < 0) {
195 if (recoff == -1)
196 return -1;
197 return 0;
198 }
199
200 if (ReadZip64EndRecord(recoff) < 0)
201 return -1;
202
203 return 0;
204}
205
206////////////////////////////////////////////////////////////////////////////////
207/// Read Zip64 end of central directory locator. Returns -1 in case of error,
208/// -2 in case end locator magic is not found (i.e. not a zip64 file) and
209/// offset of Zip64 end of central directory record in case of success.
210
212{
213 char buf[kZIP64_EDL_HEADER_SIZE];
214
215 // read and validate first the end header magic
216 fFile->Seek(pos);
217 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
219 return -2;
220 }
221
222 // read rest of the header
224 Error("ReadZip64EndLocator", "error reading %d Zip64 end locator header bytes from %s",
226 return -1;
227 }
228
232
233 if (dirdisk != 0 || totdisk != 1) {
234 Error("ReadZip64EndLocator", "only single disk archives are supported in %s",
236 return -1;
237 }
238
239 return recoff;
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Read Zip64 end of central directory record. Returns -1 in case of error
244/// and 0 in case of success.
245
247{
248 char buf[kZIP64_EDR_HEADER_SIZE];
249
250 // read and validate first the end header magic
251 fFile->Seek(pos);
252 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
254 Error("ReadZip64EndRecord", "no Zip64 end of directory record\n");
255 return -1;
256 }
257
258 // read rest of the header
260 Error("ReadZip64EndRecord", "error reading %d Zip64 end record header bytes from %s",
262 return -1;
263 }
264
267
269 fDirSize = dirsz;
270
271 return 0;
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Read the directory of the ZIP archive. Returns -1 in case of error,
276/// 0 otherwise.
277
279{
280 char buf[kDIR_HEADER_SIZE];
281 UInt_t n;
282
283 // read and validate first the header magic
285 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
286 (n = Get(buf, kZIP_MAGIC_LEN)) != kDIR_HEADER_MAGIC) {
287 Error("ReadDirectory", "wrong directory header magic in %s",
289 return -1;
290 }
291
292 // now read the full directory
293 while (n == kDIR_HEADER_MAGIC) {
294 // read the rest of the header
296 Error("ReadDirectory", "error reading %d directory bytes from %s",
298 return -1;
299 }
300
302 UInt_t flags = Get(buf + kDIR_FLAG_OFF, kDIR_FLAG_LEN);
304 UInt_t time = Get(buf + kDIR_DATE_OFF, kDIR_DATE_LEN);
308 Int_t namelen = Get(buf + kDIR_NAMELEN_OFF, kDIR_NAMELEN_LEN);
315
316 // check value sanity and the variable-length fields
319 flags & 8 ||
320 (method != kSTORED && method != kDEFLATED) ||
321 disk != 0 ||
322 csize < 0 ||
323 usize < 0 ||
324 csize > kMaxUInt ||
325 usize > kMaxUInt) {
326 Error("ReadDirectory", "inconsistency in directory data in %s",
328 return -1;
329 }
330
331 char *name = new char[namelen+1];
332 char *extra = new char[extlen];
333 char *comment = new char[commlen+1];
334 if (fFile->ReadBuffer(name, namelen) ||
335 fFile->ReadBuffer(extra, extlen) ||
336 fFile->ReadBuffer(comment, commlen)) {
337 Error("ReadDirectory", "error reading additional directory data from %s",
339 delete [] name;
340 delete [] extra;
341 delete [] comment;
342 return -1;
343 }
344 name[namelen] = '\0';
345 comment[commlen] = '\0';
346
347 // create a new archive member and store the fields
348 TZIPMember *m = new TZIPMember(name);
349 fMembers->Add(m);
350
351 m->fMethod = method;
352 m->fLevel = method == kSTORED ? 0
353 : (flags & 6)/2 == 0 ? 3 // default (:N)
354 : (flags & 6)/2 == 1 ? 9 // best (:X)
355 : (flags & 6)/2 == 2 ? 2 // fast (:F)
356 : (flags & 6)/2 == 3 ? 1 // fastest (:F)
357 : 3; // unreached
358 m->fCsize = csize;
359 m->fDsize = usize;
360 m->fCRC32 = crc32;
361 m->fModTime.Set(time, kTRUE); // DOS date/time format
362 m->fGlobalLen = extlen;
363 m->fGlobal = extra;
364 m->fComment = comment;
365 m->fAttrInt = iattr;
366 m->fAttrExt = xattr;
367 m->fPosition = offset;
368
369 delete [] name;
370 delete [] comment;
371 // extra is adopted be the TZIPMember
372
374 return -1;
375
376 if (gDebug)
377 Info("ReadDirectory", "%lld %lld %s %s",
378 m->GetDecompressedSize(), m->GetCompressedSize(),
379 m->GetModTime().AsSQLString(), m->GetName());
380
381 // done, read the next magic
382 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN)) {
383 Error("ReadDirectory", "error reading %d directory bytes from %s",
385 return -1;
386 }
387 n = Get(buf, kZIP_MAGIC_LEN);
388 }
389
390 // should now see end of archive
392 Error("ReadDirectory", "wrong end header magic in %s", fArchiveName.Data());
393 return -1;
394 }
395
396 return 0;
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Read the member header of the ZIP archive. Sets the position where
401/// the data starts in the member object. Returns -1 in case of error,
402/// 0 otherwise.
403
405{
406 // read file header to find start of data, since extra len might be
407 // different we cannot take it from the directory data
408 char buf[kENTRY_HEADER_SIZE];
409
410 // read and validate first the entry header magic
411 fFile->Seek(member->fPosition);
412 if (fFile->ReadBuffer(buf, kZIP_MAGIC_LEN) ||
414 Error("ReadMemberHeader", "wrong entry header magic in %s",
416 return -1;
417 }
418
419 // read rest of the header
421 Error("ReadMemberHeader", "error reading %d member header bytes from %s",
423 return -1;
424 }
427
428 member->fFilePosition = member->fPosition + kENTRY_HEADER_SIZE +
429 namelen + extlen;
430
431 return 0;
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Decode the Zip64 extended extra field. If global is true, decode the
436/// extra field coming from the central directory, if false decode the
437/// extra field coming from the local file header. Returns -1 in case of
438/// error, -2 in case Zip64 extra block was not found and 0 in case of
439/// success.
440
442{
443 char *buf;
444 Int_t len;
445 Int_t ret = -2;
446
447 if (global) {
448 buf = (char *) m->fGlobal;
449 len = m->fGlobalLen;
450 } else {
451 buf = (char *) m->fLocal;
452 len = m->fLocalLen;
453 }
454
455 if (!buf || !len) {
456 return ret;
457 }
458
459 Int_t off = 0;
460 while (len > 0) {
463 if (tag == kZIP64_EXTENDED_MAGIC) {
464 // The Zip64 extended entry field may contain the following values:
465 // - Original uncompressed size (8 B)
466 // - Size of compressed data (8 B)
467 // - Offset of local header record (8 B)
468 // These are all optional and only appear if the respective non-extra field is set to kMAX_SIZE (0xFFFF'FFFF).
469 // However they must appear in the above order.
471 if (m->fDsize == kMAX_SIZE && size >= kZIP64_EXTENDED_USIZE_LEN) {
472 m->fDsize = Get64(buf + off + relOff, kZIP64_EXTENDED_USIZE_LEN);
475 }
476 if (m->fCsize == kMAX_SIZE && size >= kZIP64_EXTENDED_CSIZE_LEN) {
477 m->fCsize = Get64(buf + off + relOff, kZIP64_EXTENDED_CSIZE_LEN);
480 }
481 if (m->fPosition == kMAX_SIZE && size >= kZIP64_EXTENDED_HDR_OFFSET_LEN) {
482 m->fPosition = Get64(buf + off + relOff, kZIP64_EXTENDED_HDR_OFFSET_LEN);
483 }
484
485 ret = 0;
486 }
489 }
490
491 return ret;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Find the desired member in the member array and make it the
496/// current member. Returns -1 in case member is not found, 0 otherwise.
497
499{
500 fCurMember = 0;
501
502 if (fMemberIndex > -1) {
504 if (!fCurMember)
505 return -1;
507 } else {
508 for (int i = 0; i < fMembers->GetEntriesFast(); i++) {
509 TZIPMember *m = (TZIPMember *) fMembers->At(i);
510 if (fMemberName == m->fName) {
511 fCurMember = m;
512 fMemberIndex = i;
513 break;
514 }
515 }
516 if (!fCurMember)
517 return -1;
518 }
519
521}
522
523////////////////////////////////////////////////////////////////////////////////
524/// Read a "bytes" long little-endian integer value from "buffer".
525
526UInt_t TZIPFile::Get(const void *buffer, Int_t bytes)
527{
528 UInt_t value = 0;
529
530 if (bytes > 4) {
531 Error("Get", "can not read > 4 byte integers, use Get64");
532 return value;
533 }
534#ifdef R__BYTESWAP
535 memcpy(&value, buffer, bytes);
536#else
537 const UChar_t *buf = static_cast<const unsigned char *>(buffer);
538 for (UInt_t shift = 0; bytes; shift += 8, --bytes, ++buf)
539 value += *buf << shift;
540#endif
541 return value;
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Read a 8 byte long little-endian integer value from "buffer".
546
548{
549 ULong64_t value = 0;
550
551 if (bytes != 8) {
552 Error("Get64", "bytes must be 8 (asked for %d)", bytes);
553 return value;
554 }
555
556#ifdef R__BYTESWAP
557 memcpy(&value, buffer, bytes);
558#else
559 const UChar_t *buf = static_cast<const unsigned char *>(buffer);
560 for (UInt_t shift = 0; bytes; shift += 8, --bytes, ++buf)
561 value += *buf << shift;
562#endif
563 return value;
564}
565
566////////////////////////////////////////////////////////////////////////////////
567/// Pretty print ZIP archive members.
568
570{
571 if (fMembers)
572 fMembers->Print();
573}
574
575
577
578////////////////////////////////////////////////////////////////////////////////
579/// Default ctor.
580
582{
583 fLocal = 0;
584 fLocalLen = 0;
585 fGlobal = 0;
586 fGlobalLen = 0;
587 fCRC32 = 0;
588 fAttrInt = 0;
589 fAttrExt = 0;
590 fMethod = 0;
591 fLevel = 0;
592}
593
594////////////////////////////////////////////////////////////////////////////////
595/// Create ZIP member file.
596
599{
600 fLocal = 0;
601 fLocalLen = 0;
602 fGlobal = 0;
603 fGlobalLen = 0;
604 fCRC32 = 0;
605 fAttrInt = 0;
606 fAttrExt = 0;
607 fMethod = 0;
608 fLevel = 0;
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Copy ctor.
613
616{
617 fLocal = 0;
618 fLocalLen = member.fLocalLen;
619 fGlobal = 0;
620 fGlobalLen = member.fGlobalLen;
621 fCRC32 = member.fCRC32;
622 fAttrInt = member.fAttrInt;
623 fAttrExt = member.fAttrExt;
624 fMethod = member.fMethod;
625 fLevel = member.fLevel;
626
627 if (member.fLocal) {
628 fLocal = new char [fLocalLen];
629 memcpy(fLocal, member.fLocal, fLocalLen);
630 }
631 if (member.fGlobal) {
632 fGlobal = new char [fGlobalLen];
633 memcpy(fGlobal, member.fGlobal, fGlobalLen);
634 }
635}
636
637////////////////////////////////////////////////////////////////////////////////
638/// Assignment operator.
639
641{
642 if (this != &rhs) {
644
645 delete [] (char*) fLocal;
646 delete [] (char*) fGlobal;
647
648 fLocal = 0;
649 fLocalLen = rhs.fLocalLen;
650 fGlobal = 0;
651 fGlobalLen = rhs.fGlobalLen;
652 fCRC32 = rhs.fCRC32;
653 fAttrInt = rhs.fAttrInt;
654 fAttrExt = rhs.fAttrExt;
655 fMethod = rhs.fMethod;
656 fLevel = rhs.fLevel;
657
658 if (rhs.fLocal) {
659 fLocal = new char [fLocalLen];
660 memcpy(fLocal, rhs.fLocal, fLocalLen);
661 }
662 if (rhs.fGlobal) {
663 fGlobal = new char [fGlobalLen];
664 memcpy(fGlobal, rhs.fGlobal, fGlobalLen);
665 }
666 }
667 return *this;
668}
669
670////////////////////////////////////////////////////////////////////////////////
671/// Cleanup.
672
674{
675 delete [] (char*) fLocal;
676 delete [] (char*) fGlobal;
677}
678
679////////////////////////////////////////////////////////////////////////////////
680/// Pretty print basic ZIP member info.
681
683{
684 printf("%-20lld", fDsize);
685 printf(" %s %s\n", fModTime.AsSQLString(), fName.Data());
686}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
constexpr UInt_t kMaxUInt
Definition RtypesCore.h:104
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
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
Definition TROOT.cxx:622
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:152
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:2300
virtual Long64_t GetSize() const
Returns the current file size.
Definition TFile.cxx:1337
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition TFile.cxx:1796
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
const char * Data() const
Definition TString.h:376
Describes a ZIP archive file containing multiple sub-files.
Definition TZIPFile.h:20
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:404
void Print(Option_t *option="") const override
Pretty print ZIP archive members.
Definition TZIPFile.cxx:569
Int_t DecodeZip64ExtendedExtraField(TZIPMember *m, Bool_t global=kTRUE)
Decode the Zip64 extended extra field.
Definition TZIPFile.cxx:441
Long64_t ReadZip64EndLocator(Long64_t pos)
Read Zip64 end of central directory locator.
Definition TZIPFile.cxx:211
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:246
UInt_t Get(const void *buffer, Int_t bytes)
Read a "bytes" long little-endian integer value from "buffer".
Definition TZIPFile.cxx:526
Int_t ReadDirectory()
Read the directory of the ZIP archive.
Definition TZIPFile.cxx:278
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
Int_t SetCurrentMember() override
Find the desired member in the member array and make it the current member.
Definition TZIPFile.cxx:498
ULong64_t Get64(const void *buffer, Int_t bytes)
Read a 8 byte long little-endian integer value from "buffer".
Definition TZIPFile.cxx:547
Long64_t FindEndHeader()
Find the end header of the ZIP archive. Returns 0 in case of error.
Definition TZIPFile.cxx:98
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:88
@ 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:65
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:581
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:682
~TZIPMember() override
Cleanup.
Definition TZIPFile.cxx:673
UInt_t fAttrExt
External file attributes.
Definition TZIPFile.h:167
TZIPMember & operator=(const TZIPMember &rhs)
Assignment operator.
Definition TZIPFile.cxx:640
void * fGlobal
Extra directory data.
Definition TZIPFile.h:163
void * fLocal
Extra file header data.
Definition TZIPFile.h:161
std::ostream & Info()
Definition hadd.cxx:177
const Int_t n
Definition legend1.C:16
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
TMarker m
Definition textangle.C:8