9 CArchiveDatabaseEx
*db
,
13 size_t *outBufferSize
,
15 size_t *outSizeProcessed
,
19 UInt32 folderIndex
= db
->FileIndexToFolderIndexMap
[fileIndex
];
20 SZ_RESULT res
= SZ_OK
;
22 *outSizeProcessed
= 0;
23 if (folderIndex
== (UInt32
)-1)
25 allocMain
->Free(*outBuffer
);
26 *blockIndex
= folderIndex
;
32 if (*outBuffer
== 0 || *blockIndex
!= folderIndex
)
34 CFolder
*folder
= db
->Database
.Folders
+ folderIndex
;
35 CFileSize unPackSize
= SzFolderGetUnPackSize(folder
);
37 CFileSize packSize
= SzArDbGetFolderFullPackSize(db
, folderIndex
);
41 *blockIndex
= folderIndex
;
42 allocMain
->Free(*outBuffer
);
45 RINOK(inStream
->Seek(inStream
, SzArDbGetFolderStreamPos(db
, folderIndex
, 0)));
50 inBuffer
= (Byte
*)allocTemp
->Alloc((size_t)packSize
);
52 return SZE_OUTOFMEMORY
;
54 res
= inStream
->Read(inStream
, inBuffer
, (size_t)packSize
, &processedSize
);
55 if (res
== SZ_OK
&& processedSize
!= (size_t)packSize
)
60 *outBufferSize
= (size_t)unPackSize
;
63 *outBuffer
= (Byte
*)allocMain
->Alloc((size_t)unPackSize
);
65 res
= SZE_OUTOFMEMORY
;
70 res
= SzDecode(db
->Database
.PackSizes
+
71 db
->FolderStartPackStreamIndex
[folderIndex
], folder
,
77 *outBuffer
, (size_t)unPackSize
, &outRealSize
, allocTemp
);
80 if (outRealSize
== (size_t)unPackSize
)
82 if (folder
->UnPackCRCDefined
)
84 if (!CrcVerifyDigest(folder
->UnPackCRC
, *outBuffer
, (size_t)unPackSize
))
94 allocTemp
->Free(inBuffer
);
100 CFileItem
*fileItem
= db
->Database
.Files
+ fileIndex
;
102 for(i
= db
->FolderStartFileIndex
[folderIndex
]; i
< fileIndex
; i
++)
103 *offset
+= (UInt32
)db
->Database
.Files
[i
].Size
;
104 *outSizeProcessed
= (size_t)fileItem
->Size
;
105 if (*offset
+ *outSizeProcessed
> *outBufferSize
)
108 if (fileItem
->IsFileCRCDefined
)
110 if (!CrcVerifyDigest(fileItem
->FileCRC
, *outBuffer
+ *offset
, *outSizeProcessed
))