9e052883 |
1 | 7z ANSI-C Decoder 9.35\r |
2 | ----------------------\r |
3 | \r |
4 | 7z ANSI-C provides 7z/LZMA decoding.\r |
5 | 7z ANSI-C version is simplified version ported from C++ code.\r |
6 | \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 |
10 | \r |
11 | \r |
12 | LICENSE\r |
13 | -------\r |
14 | \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 |
17 | \r |
18 | Files\r |
19 | ---------------------\r |
20 | \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 |
27 | \r |
28 | \r |
29 | How To Use\r |
30 | ----------\r |
31 | \r |
32 | You can create .7z archive with 7z.exe, 7za.exe or 7zr.exe:\r |
33 | \r |
34 | 7z.exe a archive.7z *.htm -r -mx -m0fb=255\r |
35 | \r |
36 | If you have big number of files in archive, and you need fast extracting, \r |
37 | you can use partly-solid archives:\r |
38 | \r |
39 | 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K\r |
40 | \r |
41 | In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only \r |
42 | 512KB for extracting one file from such archive.\r |
43 | \r |
44 | \r |
45 | Limitations of current version of 7z ANSI-C Decoder\r |
46 | ---------------------------------------------------\r |
47 | \r |
48 | - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.\r |
49 | - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.\r |
50 | - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.\r |
51 | \r |
52 | These limitations will be fixed in future versions.\r |
53 | \r |
54 | \r |
55 | Using 7z ANSI-C Decoder Test application:\r |
56 | -----------------------------------------\r |
57 | \r |
58 | Usage: 7zDec <command> <archive_name>\r |
59 | \r |
60 | <Command>:\r |
61 | e: Extract files from archive\r |
62 | l: List contents of archive\r |
63 | t: Test integrity of archive\r |
64 | \r |
65 | Example: \r |
66 | \r |
67 | 7zDec l archive.7z\r |
68 | \r |
69 | lists contents of archive.7z\r |
70 | \r |
71 | 7zDec e archive.7z\r |
72 | \r |
73 | extracts files from archive.7z to current folder.\r |
74 | \r |
75 | \r |
76 | How to use .7z Decoder\r |
77 | ----------------------\r |
78 | \r |
79 | Memory allocation\r |
80 | ~~~~~~~~~~~~~~~~~\r |
81 | \r |
82 | 7z Decoder uses two memory pools:\r |
83 | 1) Temporary pool\r |
84 | 2) Main pool\r |
85 | Such scheme can allow you to avoid fragmentation of allocated blocks.\r |
86 | \r |
87 | \r |
88 | Steps for using 7z decoder\r |
89 | --------------------------\r |
90 | \r |
91 | Use code at 7zMain.c as example.\r |
92 | \r |
93 | 1) Declare variables:\r |
94 | inStream /* implements ILookInStream interface */\r |
95 | CSzArEx db; /* 7z archive database structure */\r |
96 | ISzAlloc allocImp; /* memory functions for main pool */\r |
97 | ISzAlloc allocTempImp; /* memory functions for temporary pool */\r |
98 | \r |
99 | 2) call CrcGenerateTable(); function to initialize CRC structures.\r |
100 | \r |
101 | 3) call SzArEx_Init(&db); function to initialize db structures.\r |
102 | \r |
103 | 4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive\r |
104 | \r |
105 | This function opens archive "inStream" and reads headers to "db".\r |
106 | All items in "db" will be allocated with "allocMain" functions.\r |
107 | SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions.\r |
108 | \r |
109 | 5) List items or Extract items\r |
110 | \r |
111 | Listing code:\r |
112 | ~~~~~~~~~~~~~\r |
113 | \r |
114 | Use SzArEx_GetFileNameUtf16 function. Look example code in C\Util\7z\7zMain.c file. \r |
115 | \r |
116 | \r |
117 | Extracting code:\r |
118 | ~~~~~~~~~~~~~~~~\r |
119 | \r |
120 | SZ_RESULT SzAr_Extract(\r |
121 | CArchiveDatabaseEx *db,\r |
122 | ILookInStream *inStream, \r |
123 | UInt32 fileIndex, /* index of file */\r |
124 | UInt32 *blockIndex, /* index of solid block */\r |
125 | Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */\r |
126 | size_t *outBufferSize, /* buffer size for output buffer */\r |
127 | size_t *offset, /* offset of stream for required file in *outBuffer */\r |
128 | size_t *outSizeProcessed, /* size of file in *outBuffer */\r |
129 | ISzAlloc *allocMain,\r |
130 | ISzAlloc *allocTemp);\r |
131 | \r |
132 | If you need to decompress more than one file, you can send these values from previous call:\r |
133 | blockIndex, \r |
134 | outBuffer, \r |
135 | outBufferSize,\r |
136 | You can consider "outBuffer" as cache of solid block. If your archive is solid, \r |
137 | it will increase decompression speed.\r |
138 | \r |
139 | After decompressing you must free "outBuffer":\r |
140 | allocImp.Free(outBuffer);\r |
141 | \r |
142 | 6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db".\r |
143 | \r |
144 | \r |
145 | \r |
146 | \r |
147 | Memory requirements for .7z decoding \r |
148 | ------------------------------------\r |
149 | \r |
150 | Memory usage for Archive opening:\r |
151 | - Temporary pool:\r |
152 | - Memory for uncompressed .7z headers\r |
153 | - some other temporary blocks\r |
154 | - Main pool:\r |
155 | - Memory for database: \r |
156 | Estimated size of one file structures in solid archive:\r |
157 | - Size (4 or 8 Bytes)\r |
158 | - CRC32 (4 bytes)\r |
159 | - LastWriteTime (8 bytes)\r |
160 | - Some file information (4 bytes)\r |
161 | - File Name (variable length) + pointer + allocation structures\r |
162 | \r |
163 | Memory usage for archive Decompressing:\r |
164 | - Temporary pool:\r |
165 | - Memory for LZMA decompressing structures\r |
166 | - Main pool:\r |
167 | - Memory for decompressed solid block\r |
168 | - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these \r |
169 | temprorary buffers can be about 15% of solid block size. \r |
170 | \r |
171 | \r |
172 | 7z Decoder doesn't allocate memory for compressed blocks. \r |
173 | Instead of this, you must allocate buffer with desired \r |
174 | size before calling 7z Decoder. Use 7zMain.c as example.\r |
175 | \r |
176 | \r |
177 | Defines\r |
178 | -------\r |
179 | \r |
180 | _SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr.\r |
181 | \r |
182 | \r |
183 | ---\r |
184 | \r |
185 | http://www.7-zip.org\r |
186 | http://www.7-zip.org/sdk.html\r |
187 | http://www.7-zip.org/support.html\r |