Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TZIPFile.h
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Fons Rademakers 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#ifndef ROOT_TZIPFile
13#define ROOT_TZIPFile
14
15#include "TArchiveFile.h"
16
17class TZIPMember;
18
19
20class TZIPFile : public TArchiveFile {
21
22protected:
23 Long64_t fDirPos; ///< Central directory position
24 Long64_t fDirSize; ///< Central directory size
25 Long64_t fDirOffset; ///< Central directory offset (from the beginning of the archive)
26 TString fComment; ///< Archive comment
27
34 UInt_t Get(const void *buffer, Int_t bytes);
35 ULong64_t Get64(const void *buffer, Int_t bytes);
37
38 /// ZIP archive constants
40 // - Archive version required (and made)
42
43 // - Magic header constants
44 kDIR_HEADER_MAGIC = 0x02014b50,
45 kENTRY_HEADER_MAGIC = 0x04034b50,
46 kEND_HEADER_MAGIC = 0x06054b50,
49 kZIP64_EXTENDED_MAGIC = 0x0001, ///< Zip64 Extended Information Extra Field
50 kZIP_MAGIC_LEN = 4, ///< Length of magic's
51 kMAX_VAR_LEN = 0xffff, ///< Max variable-width field length
52 kMAX_SIZE = 0xffffffff, ///< Max size of things
53
54 // - Offsets into the central directory headers
72
73 // - Offsets into the Zip64 end of central directory record (EDR)
85
86 // - Offsets into the Zip64 end of central directory locator (EDL)
92
93 // - Offsets into the end-of-archive header
103
104 // - Offsets into the local entry headers
116
117 // - Offsets into the Zip64 Extended Information Extra Field
125
126 // - Compression method and strategy
127 kSTORED = 0, ///< Stored as is
128 kDEFLATED = 8 ///< Stored using deflate
129 };
130
131 TZIPFile(const TZIPFile&) = delete; // Not implemented
132 TZIPFile& operator=(const TZIPFile&) = delete; // Not implemented
133
134public:
135 TZIPFile();
136 TZIPFile(const char *archive, const char *member, TFile *file);
137 ~TZIPFile() override { }
138
139 Int_t OpenArchive() override;
140 Int_t SetCurrentMember() override;
141
142 void Print(Option_t *option = "") const override;
143
144 ClassDefOverride(TZIPFile,1) //A ZIP archive file
145};
146
147/**
148\class TZIPMember
149\ingroup IO
150A ZIP archive consists of files compressed with the popular ZLIB
151compression algorithm; this class records the information about a
152single archive member.
153*/
154
155
157
158friend class TZIPFile;
159
160private:
161 void *fLocal; ///< Extra file header data
162 UInt_t fLocalLen; ///< Length of extra file header data
163 void *fGlobal; ///< Extra directory data
164 UInt_t fGlobalLen; ///< Length of extra directory data
165 UInt_t fCRC32; ///< CRC-32 for all decompressed data
166 UInt_t fAttrInt; ///< Internal file attributes
167 UInt_t fAttrExt; ///< External file attributes
168 UInt_t fMethod; ///< Compression type
169 UInt_t fLevel; ///< Compression level
170
171public:
172 TZIPMember();
173 TZIPMember(const char *name);
174 TZIPMember(const TZIPMember &member);
175 TZIPMember &operator=(const TZIPMember &rhs);
176 ~TZIPMember() override;
177
178 void *GetLocal() const { return fLocal; }
179 UInt_t GetLocalLen() const { return fLocalLen; }
180 void *GetGlobal() const { return fGlobal; }
181 UInt_t GetGlobalLen() const { return fGlobalLen; }
182 UInt_t GetCRC32() const { return fCRC32; }
183 UInt_t GetAttrInt() const { return fAttrInt; }
184 UInt_t GetAttrExt() const { return fAttrExt; }
185 UInt_t GetMethod() const { return fMethod; }
186 UInt_t GetLevel() const { return fLevel; }
187
188 void Print(Option_t *option = "") const override;
189
190 ClassDefOverride(TZIPMember, 0); //A ZIP archive member file
191};
192
193#endif
int Int_t
Definition RtypesCore.h:45
long long Long64_t
Definition RtypesCore.h:69
unsigned long long ULong64_t
Definition RtypesCore.h:70
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
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
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
Basic string class.
Definition TString.h:139
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
~TZIPFile() override
Definition TZIPFile.h:137
TZIPFile(const TZIPFile &)=delete
void Print(Option_t *option="") const override
Pretty print ZIP archive members.
Definition TZIPFile.cxx:557
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:514
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:486
ULong64_t Get64(const void *buffer, Int_t bytes)
Read a 8 byte long little-endian integer value from "buffer".
Definition TZIPFile.cxx:535
TZIPFile & operator=(const TZIPFile &)=delete
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
EZIPConstants
ZIP archive constants.
Definition TZIPFile.h:39
@ kEND_MAGIC_OFF
Definition TZIPFile.h:94
@ 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_EDR_VERS_EXT_LEN
Definition TZIPFile.h:77
@ kENTRY_METHOD_LEN
Definition TZIPFile.h:108
@ kZIP64_EXTENDED_USIZE_OFF
Definition TZIPFile.h:120
@ kEND_HEADER_SIZE
Definition TZIPFile.h:102
@ kZIP64_EDR_SIZE_LEN
Definition TZIPFile.h:75
@ kDIR_DATE_OFF
Definition TZIPFile.h:60
@ kARCHIVE_VERSION
Definition TZIPFile.h:41
@ kZIP64_EXTENDED_CSIZE_LEN
Definition TZIPFile.h:121
@ kENTRY_CRC32_LEN
Definition TZIPFile.h:110
@ kZIP64_EXTENTED_CSIZE_OFF
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
@ kENTRY_DATE_LEN
Definition TZIPFile.h:109
@ kENTRY_CSIZE_LEN
Definition TZIPFile.h:111
@ 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
@ kZIP64_EDR_DIR_DISK_LEN
Definition TZIPFile.h:79
@ kDIR_INT_ATTR_OFF
Definition TZIPFile.h:68
@ kENTRY_NAMELEN_OFF
Definition TZIPFile.h:113
@ kZIP64_EDR_DISK_LEN
Definition TZIPFile.h:78
@ kZIP64_EDR_VERS_MADE_OFF
Definition TZIPFile.h:76
@ kDEFLATED
Stored using deflate.
Definition TZIPFile.h:128
@ kZIP64_EDR_TOTAL_HDRS_LEN
Definition TZIPFile.h:81
@ 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
@ kENTRY_VREQD_LEN
Definition TZIPFile.h:106
@ kDIR_INT_ATTR_LEN
Definition TZIPFile.h:68
@ kDIR_VREQD_LEN
Definition TZIPFile.h:57
@ kENTRY_CSIZE_OFF
Definition TZIPFile.h:111
@ kENTRY_VREQD_OFF
Definition TZIPFile.h:106
@ kDIR_EXT_ATTR_LEN
Definition TZIPFile.h:69
@ kZIP64_EDR_DISK_HDRS_OFF
Definition TZIPFile.h:80
@ kZIP64_EDR_DISK_HDRS_LEN
Definition TZIPFile.h:80
@ kENTRY_FLAG_LEN
Definition TZIPFile.h:107
@ kZIP64_EDR_VERS_MADE_LEN
Definition TZIPFile.h:76
@ kZIP64_EXTENDED_MAGIC
Zip64 Extended Information Extra Field.
Definition TZIPFile.h:49
@ kZIP64_EDL_REC_OFFSET_LEN
Definition TZIPFile.h:89
@ kZIP64_EDR_VERS_EXT_OFF
Definition TZIPFile.h:77
@ 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
@ kENTRY_USIZE_OFF
Definition TZIPFile.h:112
@ kZIP64_EDR_DIR_OFFSET_OFF
Definition TZIPFile.h:83
@ kEND_DISK_HDRS_LEN
Definition TZIPFile.h:97
@ kENTRY_METHOD_OFF
Definition TZIPFile.h:108
@ kZIP64_EDR_HEADER_MAGIC
Definition TZIPFile.h:47
@ kZIP64_EXTENDED_DISK_OFF
Definition TZIPFile.h:123
@ kZIP64_EDL_HEADER_SIZE
Definition TZIPFile.h:91
@ kZIP64_EDR_SIZE_OFF
Definition TZIPFile.h:75
@ kENTRY_MAGIC_OFF
Definition TZIPFile.h:105
@ 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_VMADE_OFF
Definition TZIPFile.h:56
@ kDIR_DATE_LEN
Definition TZIPFile.h:60
@ kDIR_METHOD_LEN
Definition TZIPFile.h:59
@ kENTRY_USIZE_LEN
Definition TZIPFile.h:112
@ kZIP64_EDR_DIR_DISK_OFF
Definition TZIPFile.h:79
@ kZIP64_EXTENDED_DISK_LEN
Definition TZIPFile.h:123
@ 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_EDR_DISK_OFF
Definition TZIPFile.h:78
@ kZIP64_EXTENDED_SIZE_OFF
Definition TZIPFile.h:119
@ kENTRY_CRC32_OFF
Definition TZIPFile.h:110
@ kEND_DISK_OFF
Definition TZIPFile.h:95
@ kZIP64_EDR_MAGIC_OFF
Definition TZIPFile.h:74
@ 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
@ kENTRY_FLAG_OFF
Definition TZIPFile.h:107
@ kENTRY_DATE_OFF
Definition TZIPFile.h:109
@ kDIR_MAGIC_OFF
Definition TZIPFile.h:55
@ kENTRY_EXTRALEN_LEN
Definition TZIPFile.h:114
@ kDIR_EXTRALEN_LEN
Definition TZIPFile.h:65
@ kDIR_VMADE_LEN
Definition TZIPFile.h:56
@ kZIP64_EDR_TOTAL_HDRS_OFF
Definition TZIPFile.h:81
@ kDIR_FLAG_OFF
Definition TZIPFile.h:58
@ kDIR_USIZE_OFF
Definition TZIPFile.h:63
@ kZIP64_EXTENDED_HDR_OFFSET_OFF
Definition TZIPFile.h:122
@ kDIR_METHOD_OFF
Definition TZIPFile.h:59
@ kZIP64_EXTENDED_SIZE
Definition TZIPFile.h:124
@ kZIP64_EDL_MAGIC_OFF
Definition TZIPFile.h:87
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 GetCRC32() const
Definition TZIPFile.h:182
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:569
void * GetGlobal() const
Definition TZIPFile.h:180
UInt_t GetAttrInt() const
Definition TZIPFile.h:183
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:670
UInt_t GetLevel() const
Definition TZIPFile.h:186
UInt_t GetGlobalLen() const
Definition TZIPFile.h:181
~TZIPMember() override
Cleanup.
Definition TZIPFile.cxx:661
UInt_t GetMethod() const
Definition TZIPFile.h:185
UInt_t fAttrExt
External file attributes.
Definition TZIPFile.h:167
TZIPMember & operator=(const TZIPMember &rhs)
Assignment operator.
Definition TZIPFile.cxx:628
void * fGlobal
Extra directory data.
Definition TZIPFile.h:163
UInt_t GetAttrExt() const
Definition TZIPFile.h:184
UInt_t GetLocalLen() const
Definition TZIPFile.h:179
void * fLocal
Extra file header data.
Definition TZIPFile.h:161
void * GetLocal() const
Definition TZIPFile.h:178
TMarker m
Definition textangle.C:8