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",
184 comment[commlen] =
'\0';
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';
345 comment[commlen] =
'\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
377 Info(
"ReadDirectory",
"%lld %lld %s %s",
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",
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;
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive...
Int_t fMemberIndex
Index of sub-file in archive.
Int_t ReadZip64EndRecord(Long64_t pos)
Read Zip64 end of central directory record.
virtual Long64_t GetSize() const
Returns the current file size.
TZIPMember & operator=(const TZIPMember &rhs)
Assignment operator.
virtual Int_t SetCurrentMember()
Find the desired member in the member array and make it the current member.
TObjArray * fMembers
Members in this archive.
void Set()
Set Date/Time to current time as reported by the system.
Long64_t fDirSize
Central directory size.
virtual Int_t OpenArchive()
Open archive and read end-header and directory.
const char * GetName() const
Returns name of object.
TString fComment
Comment field.
void * fLocal
Extra file header data.
Max variable-width field length.
TDatime GetModTime() const
Int_t ReadMemberHeader(TZIPMember *member)
Read the member header of the ZIP archive.
Long64_t FindEndHeader()
Find the end header of the ZIP archive. Returns 0 in case of error.
ClassImp(TZIPFile) TZIPFile
Default ctor.
TFile * fFile
File stream used to access the archive.
UInt_t Get(const void *buffer, Int_t bytes)
Read a "bytes" long little-endian integer value from "buffer".
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 void Info(const char *method, const char *msgfmt,...) const
Issue info message.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Long64_t fDsize
Decompressed size.
Int_t ReadEndHeader(Long64_t pos)
Read the end header of the ZIP archive including the archive comment at the current file position...
Short_t Min(Short_t a, Short_t b)
TString fMemberName
Sub-file name.
Int_t GetEntriesFast() const
TString fArchiveName
Archive file name.
TArchiveMember * fCurMember
Current archive member.
TString fComment
Archive comment.
ULong64_t Get64(const void *buffer, Int_t bytes)
Read a 8 byte long little-endian integer value from "buffer".
Long64_t fDirPos
Central directory position.
Zip64 Extended Information Extra Field.
const char * Data() const
TString fName
Name of member.
Long64_t GetDecompressedSize() const
Describes a ZIP archive file containing multiple sub-files.
void Print(Option_t *option="") const
Pretty print basic ZIP member info.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void Print(Option_t *option="") const
Pretty print ZIP archive members.
Long64_t ReadZip64EndLocator(Long64_t pos)
Read Zip64 end of central directory locator.
Long64_t fPosition
Byte position in archive.
UInt_t fGlobalLen
Length of extra directory data.
Int_t ReadDirectory()
Read the directory of the ZIP archive.
Long64_t GetCompressedSize() const
TDatime fModTime
Modification time.
UInt_t fMethod
Compression type.
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
Long64_t fDirOffset
Central directory offset (from the beginning of the archive)
UInt_t fAttrExt
External file attributes.
unsigned long long ULong64_t
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
TArchiveMember & operator=(const TArchiveMember &rhs)
Assignment operator.
virtual ~TZIPMember()
Cleanup.
Long64_t fCsize
Compressed size.
Int_t DecodeZip64ExtendedExtraField(TZIPMember *m, Bool_t global=kTRUE)
Decode the Zip64 extended extra field.
UInt_t fLocalLen
Length of extra file header data.
UInt_t fLevel
Compression level.
TObject * At(Int_t idx) const
void * fGlobal
Extra directory data.
A ZIP archive consists of files compressed with the popular ZLIB compression algorithm; this class re...
Long64_t fFilePosition
Byte position in archive where member data starts.
UInt_t fAttrInt
Internal file attributes.
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
UInt_t fCRC32
CRC-32 for all decompressed data.