100 const Int_t kBUFSIZE = 1024;
103 char buf[kBUFSIZE+4];
108 for (
Long64_t offset = 4; offset < limit; ) {
109 offset =
TMath::Min(offset + kBUFSIZE, limit);
116 Error(
"FindEndHeader",
"error reading %d bytes at %lld",
n, pos);
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) {
153 Error(
"ReadEndHeader",
"error reading %d end header bytes from %s",
166 if (disk != 0 || dirdisk != 0) {
167 Error(
"ReadHeader",
"only single disk archives are supported in %s",
171 if (dhdrs != thdrs) {
172 Error(
"ReadEndHeader",
"inconsistency in end header data in %s",
177 char *
comment =
new char[commlen+1];
179 Error(
"ReadEndHeader",
"error reading %d end header comment bytes from %s",
224 Error(
"ReadZip64EndLocator",
"error reading %d Zip64 end locator header bytes from %s",
233 if (dirdisk != 0 || totdisk != 1) {
234 Error(
"ReadZip64EndLocator",
"only single disk archives are supported in %s",
254 Error(
"ReadZip64EndRecord",
"no Zip64 end of directory record\n");
260 Error(
"ReadZip64EndRecord",
"error reading %d Zip64 end record header bytes from %s",
287 Error(
"ReadDirectory",
"wrong directory header magic in %s",
296 Error(
"ReadDirectory",
"error reading %d directory bytes from %s",
326 Error(
"ReadDirectory",
"inconsistency in directory data in %s",
331 char *
name =
new char[namelen+1];
332 char *extra =
new char[extlen];
333 char *
comment =
new char[commlen+1];
337 Error(
"ReadDirectory",
"error reading additional directory data from %s",
344 name[namelen] =
'\0';
353 : (flags & 6)/2 == 0 ? 3
354 : (flags & 6)/2 == 1 ? 9
355 : (flags & 6)/2 == 2 ? 2
356 : (flags & 6)/2 == 3 ? 1
361 m->fModTime.Set(time,
kTRUE);
362 m->fGlobalLen = extlen;
367 m->fPosition = offset;
377 Info(
"ReadDirectory",
"%lld %lld %s %s",
378 m->GetDecompressedSize(),
m->GetCompressedSize(),
379 m->GetModTime().AsSQLString(),
m->GetName());
383 Error(
"ReadDirectory",
"error reading %d directory bytes from %s",
414 Error(
"ReadMemberHeader",
"wrong entry header magic in %s",
421 Error(
"ReadMemberHeader",
"error reading %d member header bytes from %s",
448 buf = (
char *)
m->fGlobal;
451 buf = (
char *)
m->fLocal;
470 m->fPosition = offset;
519 Error(
"Get",
"can not read > 4 byte integers, use Get64");
523 memcpy(&value, buffer, bytes);
525 const UChar_t *buf =
static_cast<const unsigned char *
>(buffer);
526 for (
UInt_t shift = 0; bytes; shift += 8, --bytes, ++buf)
527 value += *buf << shift;
540 Error(
"Get64",
"bytes must be 8 (asked for %d)", bytes);
545 memcpy(&value, buffer, bytes);
547 const UChar_t *buf =
static_cast<const unsigned char *
>(buffer);
548 for (
UInt_t shift = 0; bytes; shift += 8, --bytes, ++buf)
549 value += *buf << shift;
672 printf(
"%-20lld",
fDsize);
unsigned long long ULong64_t
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.
const char * GetName() const
Returns name of object.
TDatime fModTime
Modification time.
Long64_t fPosition
Byte position in archive.
Long64_t fFilePosition
Byte position in archive where member data starts.
TArchiveMember & operator=(const TArchiveMember &rhs)
Assignment operator.
TString fName
Name of member.
Long64_t fDsize
Decompressed size.
virtual void Print(Option_t *option="") const
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.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
virtual Long64_t GetSize() const
Returns the current file size.
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
const char * Data() const
Describes a ZIP archive file containing multiple sub-files.
Long64_t fDirPos
Central directory position.
Int_t ReadMemberHeader(TZIPMember *member)
Read the member header of the ZIP archive.
Int_t DecodeZip64ExtendedExtraField(TZIPMember *m, Bool_t global=kTRUE)
Decode the Zip64 extended extra field.
virtual Int_t SetCurrentMember()
Find the desired member in the member array and make it the current member.
Long64_t ReadZip64EndLocator(Long64_t pos)
Read Zip64 end of central directory locator.
Long64_t fDirSize
Central directory size.
Int_t ReadZip64EndRecord(Long64_t pos)
Read Zip64 end of central directory record.
UInt_t Get(const void *buffer, Int_t bytes)
Read a "bytes" long little-endian integer value from "buffer".
Int_t ReadDirectory()
Read the directory of the ZIP archive.
Int_t ReadEndHeader(Long64_t pos)
Read the end header of the ZIP archive including the archive comment at the current file position.
ULong64_t Get64(const void *buffer, Int_t bytes)
Read a 8 byte long little-endian integer value from "buffer".
Long64_t FindEndHeader()
Find the end header of the ZIP archive. Returns 0 in case of error.
Long64_t fDirOffset
Central directory offset (from the beginning of the archive)
virtual Int_t OpenArchive()
Open archive and read end-header and directory.
void Print(Option_t *option="") const
Pretty print ZIP archive members.
TString fComment
Archive comment.
@ kZIP64_EXTENDED_MAGIC_OFF
@ kZIP64_EDR_DIR_SIZE_LEN
@ kZIP64_EXTENDED_USIZE_OFF
@ kZIP64_EXTENDED_CSIZE_LEN
@ kZIP64_EXTENTED_CSIZE_OFF
@ kZIP64_EDR_DIR_SIZE_OFF
@ kZIP64_EXTENDED_USIZE_LEN
@ kZIP64_EDL_TOTAL_DISK_OFF
@ kZIP64_EDL_REC_OFFSET_OFF
@ kDEFLATED
Stored using deflate.
@ kZIP64_EXTENDED_HDR_OFFSET_LEN
@ kZIP64_EXTENDED_SIZE_LEN
@ kZIP64_EXTENDED_MAGIC
Zip64 Extended Information Extra Field.
@ kZIP64_EDL_REC_OFFSET_LEN
@ kZIP64_EDL_TOTAL_DISK_LEN
@ kZIP64_EDR_DIR_OFFSET_OFF
@ kZIP64_EDR_HEADER_MAGIC
@ kZIP64_EDR_DIR_OFFSET_LEN
@ kMAX_VAR_LEN
Max variable-width field length.
@ kZIP64_EDL_HEADER_MAGIC
@ kZIP64_EXTENDED_SIZE_OFF
@ kZIP_MAGIC_LEN
Length of magic's.
@ kZIP64_EXTENDED_MAGIC_LEN
@ kZIP64_EXTENDED_HDR_OFFSET_OFF
A ZIP archive consists of files compressed with the popular ZLIB compression algorithm; this class re...
UInt_t fLevel
Compression level.
void Print(Option_t *option="") const
Pretty print basic ZIP member info.
UInt_t fGlobalLen
Length of extra directory data.
UInt_t fCRC32
CRC-32 for all decompressed data.
UInt_t fAttrInt
Internal file attributes.
UInt_t fLocalLen
Length of extra file header data.
virtual ~TZIPMember()
Cleanup.
TZIPMember()
Default ctor.
UInt_t fMethod
Compression type.
UInt_t fAttrExt
External file attributes.
TZIPMember & operator=(const TZIPMember &rhs)
Assignment operator.
void * fGlobal
Extra directory data.
void * fLocal
Extra file header data.
Short_t Min(Short_t a, Short_t b)