• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
17z Format description (2.30 Beta 25)
2-----------------------------------
3
4This file contains description of 7z archive format.
57z archive can contain files compressed with any method.
6See "Methods.txt" for description for defined compressing methods.
7
8
9Format structure Overview
10-------------------------
11
12Some fields can be optional.
13
14Archive structure
15~~~~~~~~~~~~~~~~~
16SignatureHeader
17[PackedStreams]
18[PackedStreamsForHeaders]
19[
20  Header
21  or
22  {
23    Packed Header
24    HeaderInfo
25  }
26]
27
28
29
30Header structure
31~~~~~~~~~~~~~~~~
32{
33  ArchiveProperties
34  AdditionalStreams
35  {
36    PackInfo
37    {
38      PackPos
39      NumPackStreams
40      Sizes[NumPackStreams]
41      CRCs[NumPackStreams]
42    }
43    CodersInfo
44    {
45      NumFolders
46      Folders[NumFolders]
47      {
48        NumCoders
49        CodersInfo[NumCoders]
50        {
51          ID
52          NumInStreams;
53          NumOutStreams;
54          PropertiesSize
55          Properties[PropertiesSize]
56        }
57        NumBindPairs
58        BindPairsInfo[NumBindPairs]
59        {
60          InIndex;
61          OutIndex;
62        }
63        PackedIndices
64      }
65      UnPackSize[Folders][Folders.NumOutstreams]
66      CRCs[NumFolders]
67    }
68    SubStreamsInfo
69    {
70      NumUnPackStreamsInFolders[NumFolders];
71      UnPackSizes[]
72      CRCs[]
73    }
74  }
75  MainStreamsInfo
76  {
77    (Same as in AdditionalStreams)
78  }
79  FilesInfo
80  {
81    NumFiles
82    Properties[]
83    {
84      ID
85      Size
86      Data
87    }
88  }
89}
90
91HeaderInfo structure
92~~~~~~~~~~~~~~~~~~~~
93{
94  (Same as in AdditionalStreams)
95}
96
97
98
99Notes about Notation and encoding
100---------------------------------
101
1027z uses little endian encoding.
103
1047z archive format has optional headers that are marked as
105[]
106Header
107[]
108
109REAL_UINT64 means real UINT64.
110
111UINT64 means real UINT64 encoded with the following scheme:
112
113  Size of encoding sequence depends from first byte:
114  First_Byte  Extra_Bytes        Value
115  (binary)
116  0xxxxxxx               : ( xxxxxxx           )
117  10xxxxxx    BYTE y[1]  : (  xxxxxx << (8 * 1)) + y
118  110xxxxx    BYTE y[2]  : (   xxxxx << (8 * 2)) + y
119  ...
120  1111110x    BYTE y[6]  : (       x << (8 * 6)) + y
121  11111110    BYTE y[7]  :                         y
122  11111111    BYTE y[8]  :                         y
123
124
125
126Property IDs
127------------
128
1290x00 = kEnd,
130
1310x01 = kHeader,
132
1330x02 = kArchiveProperties,
134
1350x03 = kAdditionalStreamsInfo,
1360x04 = kMainStreamsInfo,
1370x05 = kFilesInfo,
138
1390x06 = kPackInfo,
1400x07 = kUnPackInfo,
1410x08 = kSubStreamsInfo,
142
1430x09 = kSize,
1440x0A = kCRC,
145
1460x0B = kFolder,
147
1480x0C = kCodersUnPackSize,
1490x0D = kNumUnPackStream,
150
1510x0E = kEmptyStream,
1520x0F = kEmptyFile,
1530x10 = kAnti,
154
1550x11 = kName,
1560x12 = kCreationTime,
1570x13 = kLastAccessTime,
1580x14 = kLastWriteTime,
1590x15 = kWinAttributes,
1600x16 = kComment,
161
1620x17 = kEncodedHeader,
163
164
1657z format headers
166-----------------
167
168SignatureHeader
169~~~~~~~~~~~~~~~
170  BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
171
172  ArchiveVersion
173  {
174    BYTE Major;   // now = 0
175    BYTE Minor;   // now = 2
176  };
177
178  UINT32 StartHeaderCRC;
179
180  StartHeader
181  {
182    REAL_UINT64 NextHeaderOffset
183    REAL_UINT64 NextHeaderSize
184    UINT32 NextHeaderCRC
185  }
186
187
188...........................
189
190
191ArchiveProperties
192~~~~~~~~~~~~~~~~~
193BYTE NID::kArchiveProperties (0x02)
194for (;;)
195{
196  BYTE PropertyType;
197  if (aType == 0)
198    break;
199  UINT64 PropertySize;
200  BYTE PropertyData[PropertySize];
201}
202
203
204Digests (NumStreams)
205~~~~~~~~~~~~~~~~~~~~~
206  BYTE AllAreDefined
207  if (AllAreDefined == 0)
208  {
209    for(NumStreams)
210      BIT Defined
211  }
212  UINT32 CRCs[NumDefined]
213
214
215PackInfo
216~~~~~~~~~~~~
217  BYTE NID::kPackInfo  (0x06)
218  UINT64 PackPos
219  UINT64 NumPackStreams
220
221  []
222  BYTE NID::kSize    (0x09)
223  UINT64 PackSizes[NumPackStreams]
224  []
225
226  []
227  BYTE NID::kCRC      (0x0A)
228  PackStreamDigests[NumPackStreams]
229  []
230
231  BYTE NID::kEnd
232
233
234Folder
235~~~~~~
236  UINT64 NumCoders;
237  for (NumCoders)
238  {
239    BYTE
240    {
241      0:3 DecompressionMethod.IDSize
242      4:
243        0 - IsSimple
244        1 - Is not simple
245      5:
246        0 - No Attributes
247        1 - There Are Attributes
248      7:
249        0 - Last Method in Alternative_Method_List
250        1 - There are more alternative methods
251    }
252    BYTE DecompressionMethod.ID[DecompressionMethod.IDSize]
253    if (!IsSimple)
254    {
255      UINT64 NumInStreams;
256      UINT64 NumOutStreams;
257    }
258    if (DecompressionMethod[0] != 0)
259    {
260      UINT64 PropertiesSize
261      BYTE Properties[PropertiesSize]
262    }
263  }
264
265  NumBindPairs = NumOutStreamsTotal - 1;
266
267  for (NumBindPairs)
268  {
269    UINT64 InIndex;
270    UINT64 OutIndex;
271  }
272
273  NumPackedStreams = NumInStreamsTotal - NumBindPairs;
274  if (NumPackedStreams > 1)
275    for(NumPackedStreams)
276    {
277      UINT64 Index;
278    };
279
280
281
282
283Coders Info
284~~~~~~~~~~~
285
286  BYTE NID::kUnPackInfo  (0x07)
287
288
289  BYTE NID::kFolder  (0x0B)
290  UINT64 NumFolders
291  BYTE External
292  switch(External)
293  {
294    case 0:
295      Folders[NumFolders]
296    case 1:
297      UINT64 DataStreamIndex
298  }
299
300
301  BYTE ID::kCodersUnPackSize  (0x0C)
302  for(Folders)
303    for(Folder.NumOutStreams)
304     UINT64 UnPackSize;
305
306
307  []
308  BYTE NID::kCRC   (0x0A)
309  UnPackDigests[NumFolders]
310  []
311
312
313
314  BYTE NID::kEnd
315
316
317
318SubStreams Info
319~~~~~~~~~~~~~~
320  BYTE NID::kSubStreamsInfo; (0x08)
321
322  []
323  BYTE NID::kNumUnPackStream; (0x0D)
324  UINT64 NumUnPackStreamsInFolders[NumFolders];
325  []
326
327
328  []
329  BYTE NID::kSize  (0x09)
330  UINT64 UnPackSizes[]
331  []
332
333
334  []
335  BYTE NID::kCRC  (0x0A)
336  Digests[Number of streams with unknown CRC]
337  []
338
339
340  BYTE NID::kEnd
341
342
343Streams Info
344~~~~~~~~~~~~
345
346  []
347  PackInfo
348  []
349
350
351  []
352  CodersInfo
353  []
354
355
356  []
357  SubStreamsInfo
358  []
359
360  BYTE NID::kEnd
361
362
363FilesInfo
364~~~~~~~~~
365  BYTE NID::kFilesInfo;  (0x05)
366  UINT64 NumFiles
367
368  for (;;)
369  {
370    BYTE PropertyType;
371    if (aType == 0)
372      break;
373
374    UINT64 Size;
375
376    switch(PropertyType)
377    {
378      kEmptyStream:   (0x0E)
379        for(NumFiles)
380          BIT IsEmptyStream
381
382      kEmptyFile:     (0x0F)
383        for(EmptyStreams)
384          BIT IsEmptyFile
385
386      kAnti:          (0x10)
387        for(EmptyStreams)
388          BIT IsAntiFile
389
390      case kCreationTime:   (0x12)
391      case kLastAccessTime: (0x13)
392      case kLastWriteTime:  (0x14)
393        BYTE AllAreDefined
394        if (AllAreDefined == 0)
395        {
396          for(NumFiles)
397            BIT TimeDefined
398        }
399        BYTE External;
400        if(External != 0)
401          UINT64 DataIndex
402        []
403        for(Definded Items)
404          UINT32 Time
405        []
406
407      kNames:     (0x11)
408        BYTE External;
409        if(External != 0)
410          UINT64 DataIndex
411        []
412        for(Files)
413        {
414          wchar_t Names[NameSize];
415          wchar_t 0;
416        }
417        []
418
419      kAttributes:  (0x15)
420        BYTE AllAreDefined
421        if (AllAreDefined == 0)
422        {
423          for(NumFiles)
424            BIT AttributesAreDefined
425        }
426        BYTE External;
427        if(External != 0)
428          UINT64 DataIndex
429        []
430        for(Definded Attributes)
431          UINT32 Attributes
432        []
433    }
434  }
435
436
437Header
438~~~~~~
439  BYTE NID::kHeader (0x01)
440
441  []
442  ArchiveProperties
443  []
444
445  []
446  BYTE NID::kAdditionalStreamsInfo; (0x03)
447  StreamsInfo
448  []
449
450  []
451  BYTE NID::kMainStreamsInfo;    (0x04)
452  StreamsInfo
453  []
454
455  []
456  FilesInfo
457  []
458
459  BYTE NID::kEnd
460
461
462HeaderInfo
463~~~~~~~~~~
464  []
465  BYTE NID::kEncodedHeader; (0x17)
466  StreamsInfo for Encoded Header
467  []
468
469
470---
471End of document
472