• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 7z/7zHeader.h
2 
3 #ifndef ZIP7_INC_7Z_HEADER_H
4 #define ZIP7_INC_7Z_HEADER_H
5 
6 #include "../../../Common/MyTypes.h"
7 
8 namespace NArchive {
9 namespace N7z {
10 
11 const unsigned kSignatureSize = 6;
12 extern Byte kSignature[kSignatureSize];
13 
14 // #define Z7_7Z_VOL
15 // 7z-MultiVolume is not finished yet.
16 // It can work already, but I still do not like some
17 // things of that new multivolume format.
18 // So please keep it commented.
19 
20 #ifdef Z7_7Z_VOL
21 extern Byte kFinishSignature[kSignatureSize];
22 #endif
23 
24 struct CArchiveVersion
25 {
26   Byte Major;
27   Byte Minor;
28 };
29 
30 const Byte kMajorVersion = 0;
31 
32 struct CStartHeader
33 {
34   UInt64 NextHeaderOffset;
35   UInt64 NextHeaderSize;
36   UInt32 NextHeaderCRC;
37 };
38 
39 const UInt32 kStartHeaderSize = 20;
40 
41 #ifdef Z7_7Z_VOL
42 struct CFinishHeader: public CStartHeader
43 {
44   UInt64 ArchiveStartOffset;  // data offset from end if that struct
45   UInt64 AdditionalStartBlockSize; // start  signature & start header size
46 };
47 
48 const UInt32 kFinishHeaderSize = kStartHeaderSize + 16;
49 #endif
50 
51 namespace NID
52 {
53   enum EEnum
54   {
55     kEnd,
56 
57     kHeader,
58 
59     kArchiveProperties,
60 
61     kAdditionalStreamsInfo,
62     kMainStreamsInfo,
63     kFilesInfo,
64 
65     kPackInfo,
66     kUnpackInfo,
67     kSubStreamsInfo,
68 
69     kSize,
70     kCRC,
71 
72     kFolder,
73 
74     kCodersUnpackSize,
75     kNumUnpackStream,
76 
77     kEmptyStream,
78     kEmptyFile,
79     kAnti,
80 
81     kName,
82     kCTime,
83     kATime,
84     kMTime,
85     kWinAttrib,
86     kComment,
87 
88     kEncodedHeader,
89 
90     kStartPos,
91     kDummy
92 
93     // kNtSecure,
94     // kParent,
95     // kIsAux
96   };
97 }
98 
99 
100 const UInt32 k_Copy = 0;
101 const UInt32 k_Delta = 3;
102 const UInt32 k_ARM64 = 0xa;
103 
104 const UInt32 k_LZMA2 = 0x21;
105 
106 const UInt32 k_SWAP2 = 0x20302;
107 const UInt32 k_SWAP4 = 0x20304;
108 
109 const UInt32 k_LZMA  = 0x30101;
110 const UInt32 k_PPMD  = 0x30401;
111 
112 const UInt32 k_Deflate   = 0x40108;
113 const UInt32 k_Deflate64 = 0x40109;
114 const UInt32 k_BZip2     = 0x40202;
115 
116 const UInt32 k_BCJ   = 0x3030103;
117 const UInt32 k_BCJ2  = 0x303011B;
118 const UInt32 k_PPC   = 0x3030205;
119 const UInt32 k_IA64  = 0x3030401;
120 const UInt32 k_ARM   = 0x3030501;
121 const UInt32 k_ARMT  = 0x3030701;
122 const UInt32 k_SPARC = 0x3030805;
123 
124 const UInt32 k_AES   = 0x6F10701;
125 
126 // const UInt32 k_ZSTD = 0x4015D; // winzip zstd
127 // 0x4F71101, 7z-zstd
128 
IsFilterMethod(UInt64 m)129 static inline bool IsFilterMethod(UInt64 m)
130 {
131   if (m > (UInt32)0xFFFFFFFF)
132     return false;
133   switch ((UInt32)m)
134   {
135     case k_Delta:
136     case k_ARM64:
137     case k_BCJ:
138     case k_BCJ2:
139     case k_PPC:
140     case k_IA64:
141     case k_ARM:
142     case k_ARMT:
143     case k_SPARC:
144     case k_SWAP2:
145     case k_SWAP4:
146       return true;
147   }
148   return false;
149 }
150 
151 }}
152 
153 #endif
154