123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- 7z Format description (2.30 Beta 25)
- -----------------------------------
- This file contains description of 7z archive format.
- 7z archive can contain files compressed with any method.
- See "Methods.txt" for description for defined compressing methods.
- Format structure Overview
- -------------------------
- Some fields can be optional.
- Archive structure
- ~~~~~~~~~~~~~~~~~
- SignatureHeader
- [PackedStreams]
- [PackedStreamsForHeaders]
- [
- Header
- or
- {
- Packed Header
- HeaderInfo
- }
- ]
- Header structure
- ~~~~~~~~~~~~~~~~
- {
- ArchiveProperties
- AdditionalStreams
- {
- PackInfo
- {
- PackPos
- NumPackStreams
- Sizes[NumPackStreams]
- CRCs[NumPackStreams]
- }
- CodersInfo
- {
- NumFolders
- Folders[NumFolders]
- {
- NumCoders
- CodersInfo[NumCoders]
- {
- ID
- NumInStreams;
- NumOutStreams;
- PropertiesSize
- Properties[PropertiesSize]
- }
- NumBindPairs
- BindPairsInfo[NumBindPairs]
- {
- InIndex;
- OutIndex;
- }
- PackedIndices
- }
- UnPackSize[Folders][Folders.NumOutstreams]
- CRCs[NumFolders]
- }
- SubStreamsInfo
- {
- NumUnPackStreamsInFolders[NumFolders];
- UnPackSizes[]
- CRCs[]
- }
- }
- MainStreamsInfo
- {
- (Same as in AdditionalStreams)
- }
- FilesInfo
- {
- NumFiles
- Properties[]
- {
- ID
- Size
- Data
- }
- }
- }
- HeaderInfo structure
- ~~~~~~~~~~~~~~~~~~~~
- {
- (Same as in AdditionalStreams)
- }
- Notes about Notation and encoding
- ---------------------------------
- 7z uses little endian encoding.
- 7z archive format has optional headers that are marked as
- []
- Header
- []
- REAL_UINT64 means real UINT64.
- UINT64 means real UINT64 encoded with the following scheme:
- Size of encoding sequence depends from first byte:
- First_Byte Extra_Bytes Value
- (binary)
- 0xxxxxxx : ( xxxxxxx )
- 10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y
- 110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y
- ...
- 1111110x BYTE y[6] : ( x << (8 * 6)) + y
- 11111110 BYTE y[7] : y
- 11111111 BYTE y[8] : y
- Property IDs
- ------------
- 0x00 = kEnd,
- 0x01 = kHeader,
- 0x02 = kArchiveProperties,
-
- 0x03 = kAdditionalStreamsInfo,
- 0x04 = kMainStreamsInfo,
- 0x05 = kFilesInfo,
-
- 0x06 = kPackInfo,
- 0x07 = kUnPackInfo,
- 0x08 = kSubStreamsInfo,
- 0x09 = kSize,
- 0x0A = kCRC,
- 0x0B = kFolder,
- 0x0C = kCodersUnPackSize,
- 0x0D = kNumUnPackStream,
- 0x0E = kEmptyStream,
- 0x0F = kEmptyFile,
- 0x10 = kAnti,
- 0x11 = kName,
- 0x12 = kCreationTime,
- 0x13 = kLastAccessTime,
- 0x14 = kLastWriteTime,
- 0x15 = kWinAttributes,
- 0x16 = kComment,
- 0x17 = kEncodedHeader,
- 7z format headers
- -----------------
- SignatureHeader
- ~~~~~~~~~~~~~~~
- BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
- ArchiveVersion
- {
- BYTE Major; // now = 0
- BYTE Minor; // now = 2
- };
- UINT32 StartHeaderCRC;
- StartHeader
- {
- REAL_UINT64 NextHeaderOffset
- REAL_UINT64 NextHeaderSize
- UINT32 NextHeaderCRC
- }
- ...........................
- ArchiveProperties
- ~~~~~~~~~~~~~~~~~
- BYTE NID::kArchiveProperties (0x02)
- for (;;)
- {
- BYTE PropertyType;
- if (aType == 0)
- break;
- UINT64 PropertySize;
- BYTE PropertyData[PropertySize];
- }
- Digests (NumStreams)
- ~~~~~~~~~~~~~~~~~~~~~
- BYTE AllAreDefined
- if (AllAreDefined == 0)
- {
- for(NumStreams)
- BIT Defined
- }
- UINT32 CRCs[NumDefined]
- PackInfo
- ~~~~~~~~~~~~
- BYTE NID::kPackInfo (0x06)
- UINT64 PackPos
- UINT64 NumPackStreams
- []
- BYTE NID::kSize (0x09)
- UINT64 PackSizes[NumPackStreams]
- []
- []
- BYTE NID::kCRC (0x0A)
- PackStreamDigests[NumPackStreams]
- []
- BYTE NID::kEnd
- Folder
- ~~~~~~
- UINT64 NumCoders;
- for (NumCoders)
- {
- BYTE
- {
- 0:3 DecompressionMethod.IDSize
- 4:
- 0 - IsSimple
- 1 - Is not simple
- 5:
- 0 - No Attributes
- 1 - There Are Attributes
- 7:
- 0 - Last Method in Alternative_Method_List
- 1 - There are more alternative methods
- }
- BYTE DecompressionMethod.ID[DecompressionMethod.IDSize]
- if (!IsSimple)
- {
- UINT64 NumInStreams;
- UINT64 NumOutStreams;
- }
- if (DecompressionMethod[0] != 0)
- {
- UINT64 PropertiesSize
- BYTE Properties[PropertiesSize]
- }
- }
-
- NumBindPairs = NumOutStreamsTotal - 1;
- for (NumBindPairs)
- {
- UINT64 InIndex;
- UINT64 OutIndex;
- }
- NumPackedStreams = NumInStreamsTotal - NumBindPairs;
- if (NumPackedStreams > 1)
- for(NumPackedStreams)
- {
- UINT64 Index;
- };
- Coders Info
- ~~~~~~~~~~~
- BYTE NID::kUnPackInfo (0x07)
- BYTE NID::kFolder (0x0B)
- UINT64 NumFolders
- BYTE External
- switch(External)
- {
- case 0:
- Folders[NumFolders]
- case 1:
- UINT64 DataStreamIndex
- }
- BYTE ID::kCodersUnPackSize (0x0C)
- for(Folders)
- for(Folder.NumOutStreams)
- UINT64 UnPackSize;
- []
- BYTE NID::kCRC (0x0A)
- UnPackDigests[NumFolders]
- []
-
- BYTE NID::kEnd
- SubStreams Info
- ~~~~~~~~~~~~~~
- BYTE NID::kSubStreamsInfo; (0x08)
- []
- BYTE NID::kNumUnPackStream; (0x0D)
- UINT64 NumUnPackStreamsInFolders[NumFolders];
- []
- []
- BYTE NID::kSize (0x09)
- UINT64 UnPackSizes[]
- []
- []
- BYTE NID::kCRC (0x0A)
- Digests[Number of streams with unknown CRC]
- []
-
- BYTE NID::kEnd
- Streams Info
- ~~~~~~~~~~~~
- []
- PackInfo
- []
- []
- CodersInfo
- []
- []
- SubStreamsInfo
- []
- BYTE NID::kEnd
- FilesInfo
- ~~~~~~~~~
- BYTE NID::kFilesInfo; (0x05)
- UINT64 NumFiles
- for (;;)
- {
- BYTE PropertyType;
- if (aType == 0)
- break;
- UINT64 Size;
- switch(PropertyType)
- {
- kEmptyStream: (0x0E)
- for(NumFiles)
- BIT IsEmptyStream
- kEmptyFile: (0x0F)
- for(EmptyStreams)
- BIT IsEmptyFile
- kAnti: (0x10)
- for(EmptyStreams)
- BIT IsAntiFile
-
- case kCreationTime: (0x12)
- case kLastAccessTime: (0x13)
- case kLastWriteTime: (0x14)
- BYTE AllAreDefined
- if (AllAreDefined == 0)
- {
- for(NumFiles)
- BIT TimeDefined
- }
- BYTE External;
- if(External != 0)
- UINT64 DataIndex
- []
- for(Definded Items)
- UINT32 Time
- []
-
- kNames: (0x11)
- BYTE External;
- if(External != 0)
- UINT64 DataIndex
- []
- for(Files)
- {
- wchar_t Names[NameSize];
- wchar_t 0;
- }
- []
- kAttributes: (0x15)
- BYTE AllAreDefined
- if (AllAreDefined == 0)
- {
- for(NumFiles)
- BIT AttributesAreDefined
- }
- BYTE External;
- if(External != 0)
- UINT64 DataIndex
- []
- for(Definded Attributes)
- UINT32 Attributes
- []
- }
- }
- Header
- ~~~~~~
- BYTE NID::kHeader (0x01)
- []
- ArchiveProperties
- []
- []
- BYTE NID::kAdditionalStreamsInfo; (0x03)
- StreamsInfo
- []
- []
- BYTE NID::kMainStreamsInfo; (0x04)
- StreamsInfo
- []
- []
- FilesInfo
- []
- BYTE NID::kEnd
- HeaderInfo
- ~~~~~~~~~~
- []
- BYTE NID::kEncodedHeader; (0x17)
- StreamsInfo for Encoded Header
- []
- ---
- End of document
|