99 const Int_t kBUFSIZE = 1024;
102 char buf[kBUFSIZE+4];
107 for (
Long64_t offset = 4; offset < limit; ) {
108 offset = std::min(offset + kBUFSIZE, limit);
114 if (
fFile->ReadBuffer(buf,
n)) {
115 Error(
"FindEndHeader",
"error reading %d bytes at %lld",
n, pos);
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) {
152 Error(
"ReadEndHeader",
"error reading %d end header bytes from %s",
165 if (disk != 0 || dirdisk != 0) {
166 Error(
"ReadHeader",
"only single disk archives are supported in %s",
170 if (dhdrs != thdrs) {
171 Error(
"ReadEndHeader",
"inconsistency in end header data in %s",
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",
183 comment[commlen] =
'\0';
223 Error(
"ReadZip64EndLocator",
"error reading %d Zip64 end locator header bytes from %s",
232 if (dirdisk != 0 || totdisk != 1) {
233 Error(
"ReadZip64EndLocator",
"only single disk archives are supported in %s",
253 Error(
"ReadZip64EndRecord",
"no Zip64 end of directory record\n");
259 Error(
"ReadZip64EndRecord",
"error reading %d Zip64 end record header bytes from %s",
286 Error(
"ReadDirectory",
"wrong directory header magic in %s",
295 Error(
"ReadDirectory",
"error reading %d directory bytes from %s",
325 Error(
"ReadDirectory",
"inconsistency in directory data in %s",
330 char *
name =
new char[namelen+1];
331 char *extra =
new char[extlen];
332 char *comment =
new char[commlen+1];
334 fFile->ReadBuffer(extra, extlen) ||
335 fFile->ReadBuffer(comment, commlen)) {
336 Error(
"ReadDirectory",
"error reading additional directory data from %s",
343 name[namelen] =
'\0';
344 comment[commlen] =
'\0';
352 : (flags & 6)/2 == 0 ? 3
353 : (flags & 6)/2 == 1 ? 9
354 : (flags & 6)/2 == 2 ? 2
355 : (flags & 6)/2 == 3 ? 1
360 m->fModTime.Set(time,
kTRUE);
361 m->fGlobalLen = extlen;
363 m->fComment = comment;
366 m->fPosition = offset;
376 Info(
"ReadDirectory",
"%lld %lld %s %s",
377 m->GetDecompressedSize(),
m->GetCompressedSize(),
378 m->GetModTime().AsSQLString(),
m->GetName());
382 Error(
"ReadDirectory",
"error reading %d directory bytes from %s",
413 Error(
"ReadMemberHeader",
"wrong entry header magic in %s",
420 Error(
"ReadMemberHeader",
"error reading %d member header bytes from %s",
447 buf = (
char *)
m->fGlobal;
450 buf = (
char *)
m->fLocal;
507 for (
int i = 0; i <
fMembers->GetEntriesFast(); i++) {
530 Error(
"Get",
"can not read > 4 byte integers, use Get64");
534 memcpy(&value, buffer, bytes);
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;
551 Error(
"Get64",
"bytes must be 8 (asked for %d)", bytes);
556 memcpy(&value, buffer, bytes);
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;
626 fLocal = new char [fLocalLen];
627 memcpy(fLocal, member.fLocal, fLocalLen);
630 fGlobal = new char [fGlobalLen];
631 memcpy(fGlobal, member.fGlobal, fGlobalLen);
682 printf(
"%-20lld",
fDsize);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
constexpr UInt_t kMaxUInt
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
const char Option_t
Option string (const char).
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.
TArchiveFile(const TArchiveFile &)=delete
Not implemented because TArchiveFile can not be copied.
TFile * fFile
File stream used to access the archive.
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.
TArchiveMember()
Default ctor.
Long64_t fDsize
Decompressed size.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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.
Long64_t fDirPos
Central directory position.
Int_t ReadMemberHeader(TZIPMember *member)
Read the member header of the ZIP archive.
void Print(Option_t *option="") const override
Pretty print ZIP archive members.
Int_t DecodeZip64ExtendedExtraField(TZIPMember *m, Bool_t global=kTRUE)
Decode the Zip64 extended extra field.
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.
Int_t SetCurrentMember() override
Find the desired member in the member array and make it the current member.
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).
TString fComment
Archive comment.
Int_t OpenArchive() override
Open archive and read end-header and directory.
@ kZIP64_EXTENDED_MAGIC_OFF
@ kZIP64_EDR_DIR_SIZE_LEN
@ kZIP64_EXTENDED_USIZE_OFF
@ kZIP64_EXTENDED_CSIZE_LEN
@ kZIP64_EDR_DIR_SIZE_OFF
@ kZIP64_EXTENDED_USIZE_LEN
@ kZIP64_EDL_TOTAL_DISK_OFF
@ kMAX_SIZE
Max size of things.
@ 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
A ZIP archive consists of files compressed with the popular ZLIB compression algorithm; this class re...
UInt_t fLevel
Compression level.
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.
TZIPMember()
Default ctor.
UInt_t fMethod
Compression type.
void Print(Option_t *option="") const override
Pretty print basic ZIP member info.
~TZIPMember() override
Cleanup.
UInt_t fAttrExt
External file attributes.
TZIPMember & operator=(const TZIPMember &rhs)
Assignment operator.
void * fGlobal
Extra directory data.
void * fLocal
Extra file header data.