1 7z ANSI-C Decoder 4.62
\r
2 ----------------------
\r
4 7z ANSI-C provides 7z/LZMA decoding.
\r
5 7z ANSI-C version is simplified version ported from C++ code.
\r
7 LZMA is default and general compression method of 7z format
\r
8 in 7-Zip compression program (www.7-zip.org). LZMA provides high
\r
9 compression ratio and very fast decompression.
\r
15 7z ANSI-C Decoder is part of the LZMA SDK.
\r
16 LZMA SDK is written and placed in the public domain by Igor Pavlov.
\r
19 ---------------------
\r
21 7zDecode.* - Low level 7z decoding
\r
22 7zExtract.* - High level 7z decoding
\r
23 7zHeader.* - .7z format constants
\r
24 7zIn.* - .7z archive opening
\r
25 7zItem.* - .7z structures
\r
26 7zMain.c - Test application
\r
32 You must download 7-Zip program from www.7-zip.org.
\r
34 You can create .7z archive with 7z.exe or 7za.exe:
\r
36 7za.exe a archive.7z *.htm -r -mx -m0fb=255
\r
38 If you have big number of files in archive, and you need fast extracting,
\r
39 you can use partly-solid archives:
\r
41 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K
\r
43 In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only
\r
44 512KB for extracting one file from such archive.
\r
47 Limitations of current version of 7z ANSI-C Decoder
\r
48 ---------------------------------------------------
\r
50 - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.
\r
51 - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.
\r
52 - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
\r
54 These limitations will be fixed in future versions.
\r
57 Using 7z ANSI-C Decoder Test application:
\r
58 -----------------------------------------
\r
60 Usage: 7zDec <command> <archive_name>
\r
63 e: Extract files from archive
\r
64 l: List contents of archive
\r
65 t: Test integrity of archive
\r
71 lists contents of archive.7z
\r
75 extracts files from archive.7z to current folder.
\r
78 How to use .7z Decoder
\r
79 ----------------------
\r
84 7z Decoder uses two memory pools:
\r
87 Such scheme can allow you to avoid fragmentation of allocated blocks.
\r
90 Steps for using 7z decoder
\r
91 --------------------------
\r
93 Use code at 7zMain.c as example.
\r
95 1) Declare variables:
\r
96 inStream /* implements ILookInStream interface */
\r
97 CSzArEx db; /* 7z archive database structure */
\r
98 ISzAlloc allocImp; /* memory functions for main pool */
\r
99 ISzAlloc allocTempImp; /* memory functions for temporary pool */
\r
101 2) call CrcGenerateTable(); function to initialize CRC structures.
\r
103 3) call SzArEx_Init(&db); function to initialize db structures.
\r
105 4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive
\r
107 This function opens archive "inStream" and reads headers to "db".
\r
108 All items in "db" will be allocated with "allocMain" functions.
\r
109 SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions.
\r
111 5) List items or Extract items
\r
117 for (i = 0; i < db.db.NumFiles; i++)
\r
119 CFileItem *f = db.db.Files + i;
\r
120 printf("%10d %s\n", (int)f->Size, f->Name);
\r
127 SZ_RESULT SzAr_Extract(
\r
128 CArchiveDatabaseEx *db,
\r
129 ILookInStream *inStream,
\r
130 UInt32 fileIndex, /* index of file */
\r
131 UInt32 *blockIndex, /* index of solid block */
\r
132 Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
\r
133 size_t *outBufferSize, /* buffer size for output buffer */
\r
134 size_t *offset, /* offset of stream for required file in *outBuffer */
\r
135 size_t *outSizeProcessed, /* size of file in *outBuffer */
\r
136 ISzAlloc *allocMain,
\r
137 ISzAlloc *allocTemp);
\r
139 If you need to decompress more than one file, you can send these values from previous call:
\r
143 You can consider "outBuffer" as cache of solid block. If your archive is solid,
\r
144 it will increase decompression speed.
\r
146 After decompressing you must free "outBuffer":
\r
147 allocImp.Free(outBuffer);
\r
149 6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db".
\r
154 Memory requirements for .7z decoding
\r
155 ------------------------------------
\r
157 Memory usage for Archive opening:
\r
159 - Memory for uncompressed .7z headers
\r
160 - some other temporary blocks
\r
162 - Memory for database:
\r
163 Estimated size of one file structures in solid archive:
\r
164 - Size (4 or 8 Bytes)
\r
166 - LastWriteTime (8 bytes)
\r
167 - Some file information (4 bytes)
\r
168 - File Name (variable length) + pointer + allocation structures
\r
170 Memory usage for archive Decompressing:
\r
172 - Memory for LZMA decompressing structures
\r
174 - Memory for decompressed solid block
\r
175 - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these
\r
176 temprorary buffers can be about 15% of solid block size.
\r
179 7z Decoder doesn't allocate memory for compressed blocks.
\r
180 Instead of this, you must allocate buffer with desired
\r
181 size before calling 7z Decoder. Use 7zMain.c as example.
\r
187 _SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr.
\r
192 http://www.7-zip.org
\r
193 http://www.7-zip.org/sdk.html
\r
194 http://www.7-zip.org/support.html
\r