AutoIt Requires Chilkat v11.0.0+
AutoIt
Decompress Large Binary File in Blocks
See more Compression Examples
Decompresses a large binary file in blocks.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oFacSrc = ObjCreate("Chilkat.FileAccess")
$oFacDest = ObjCreate("Chilkat.FileAccess")
; Open a previously compressed file for decompressing.
; See Compress Large File in Blocks
$bSuccess = $oFacSrc.OpenForRead("c:/temp/qa_output/compressedBmp.dat")
If ($bSuccess = False) Then
ConsoleWrite($oFacSrc.LastErrorText & @CRLF)
Exit
EndIf
; If we compress in 32K chunks, find out how many blocks there will be.
Local $iBlockSize = 32768
Local $iNumBlocks = $oFacSrc.GetNumBlocks($iBlockSize)
; Open an output file for the decompressed data.
$bSuccess = $oFacDest.OpenForWrite("c:/temp/qa_output/decompressed.bmp")
If ($bSuccess = False) Then
ConsoleWrite($oFacDest.LastErrorText & @CRLF)
Exit
EndIf
$oCompress = ObjCreate("Chilkat.Compression")
$oCompress.Algorithm = "deflate"
Local $oDecompressedBytes
Local $oCompressedBytes
; Assuming numBlocks > 1
$oCompress.FirstChunk = True
$oCompress.LastChunk = False
Local $i = 0
While $i < $iNumBlocks
$oCompressedBytes = $oFacSrc.ReadBlock($i,$iBlockSize)
$oDecompressedBytes = $oCompress.DecompressBytes($oCompressedBytes)
$oFacDest.FileWrite($oDecompressedBytes)
$i = $i + 1
$oCompress.FirstChunk = False
If ($i = ($iNumBlocks - 1)) Then
$oCompress.LastChunk = True
EndIf
Wend
$oFacSrc.FileClose
$oFacDest.FileClose
ConsoleWrite("Finished decompressing file." & @CRLF)