1 /* 7z.h -- 7z interface
\r
2 2018-07-02 : Igor Pavlov : Public domain */
\r
11 #define k7zStartHeaderSize 0x20
\r
12 #define k7zSignatureSize 6
\r
14 extern const Byte k7zSignature[k7zSignatureSize];
\r
22 /* CSzCoderInfo & CSzFolder support only default methods */
\r
38 #define SZ_NUM_CODERS_IN_FOLDER_MAX 4
\r
39 #define SZ_NUM_BONDS_IN_FOLDER_MAX 3
\r
40 #define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4
\r
46 UInt32 NumPackStreams;
\r
47 UInt32 UnpackStream;
\r
48 UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
\r
49 CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX];
\r
50 CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];
\r
54 SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd);
\r
64 Byte *Defs; /* MSB 0 bit numbering */
\r
70 Byte *Defs; /* MSB 0 bit numbering */
\r
72 CNtfsFileTime *Vals;
\r
75 #define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
\r
77 #define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
\r
81 UInt32 NumPackStreams;
\r
84 UInt64 *PackPositions; // NumPackStreams + 1
\r
85 CSzBitUi32s FolderCRCs; // NumFolders
\r
87 size_t *FoCodersOffsets; // NumFolders + 1
\r
88 UInt32 *FoStartPackStreamIndex; // NumFolders + 1
\r
89 UInt32 *FoToCoderUnpackSizes; // NumFolders + 1
\r
90 Byte *FoToMainUnpackSizeIndex; // NumFolders
\r
91 UInt64 *CoderUnpackSizes; // for all coders in all folders
\r
98 UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
\r
100 SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
\r
101 ILookInStream *stream, UInt64 startPos,
\r
102 Byte *outBuffer, size_t outSize,
\r
103 ISzAllocPtr allocMain);
\r
109 UInt64 startPosAfterHeader;
\r
114 UInt64 *UnpackPositions; // NumFiles + 1
\r
115 // Byte *IsEmptyFiles;
\r
119 CSzBitUi32s Attribs;
\r
120 // CSzBitUi32s Parents;
\r
124 UInt32 *FolderToFile; // NumFolders + 1
\r
125 UInt32 *FileToFolder; // NumFiles
\r
127 size_t *FileNameOffsets; /* in 2-byte steps */
\r
128 Byte *FileNames; /* UTF-16-LE */
\r
131 #define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i))
\r
133 #define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i])
\r
135 void SzArEx_Init(CSzArEx *p);
\r
136 void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc);
\r
137 UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
\r
138 int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
\r
141 if dest == NULL, the return value specifies the required size of the buffer,
\r
142 in 16-bit characters, including the null-terminating character.
\r
143 if dest != NULL, the return value specifies the number of 16-bit characters that
\r
144 are written to the dest, including the null-terminating character. */
\r
146 size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
\r
149 size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
\r
150 UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
\r
156 SzArEx_Extract extracts file from archive
\r
158 *outBuffer must be 0 before first call for each new archive.
\r
161 If you need to decompress more than one file, you can send
\r
162 these values from previous call:
\r
166 You can consider "*outBuffer" as cache of solid block. If your archive is solid,
\r
167 it will increase decompression speed.
\r
169 If you use external function, you can declare these 3 cache variables
\r
170 (blockIndex, outBuffer, outBufferSize) as static in that external function.
\r
172 Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
\r
175 SRes SzArEx_Extract(
\r
177 ILookInStream *inStream,
\r
178 UInt32 fileIndex, /* index of file */
\r
179 UInt32 *blockIndex, /* index of solid block */
\r
180 Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
\r
181 size_t *outBufferSize, /* buffer size for output buffer */
\r
182 size_t *offset, /* offset of stream for required file in *outBuffer */
\r
183 size_t *outSizeProcessed, /* size of file in *outBuffer */
\r
184 ISzAllocPtr allocMain,
\r
185 ISzAllocPtr allocTemp);
\r
189 SzArEx_Open Errors:
\r
190 SZ_ERROR_NO_ARCHIVE
\r
192 SZ_ERROR_UNSUPPORTED
\r
199 SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,
\r
200 ISzAllocPtr allocMain, ISzAllocPtr allocTemp);
\r