Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) Decompress Large Binary File in BlocksDecompresses a large binary file in blocks. This example uses BeginDecompressBytes, MoreDecompressBytes, and EndDecompressBytes.
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set facSrc [new_CkFileAccess] set facDest [new_CkFileAccess] # Open a previously compressed file for decompressing. # See Compress Large File in Blocks set success [CkFileAccess_OpenForRead $facSrc "qa_data/bmp/compressedBmp.dat"] if {$success != 1} then { puts [CkFileAccess_lastErrorText $facSrc] delete_CkFileAccess $facSrc delete_CkFileAccess $facDest exit } # If we compress in 32K chunks, find out how many blocks there will be. set blockSize 32768 set numBlocks [CkFileAccess_GetNumBlocks $facSrc $blockSize] # Open an output file for the decompressed data. set success [CkFileAccess_OpenForWrite $facDest "qa_output/decompressed.bmp"] if {$success != 1} then { puts [CkFileAccess_lastErrorText $facDest] delete_CkFileAccess $facSrc delete_CkFileAccess $facDest exit } set compress [new_CkCompression] CkCompression_put_Algorithm $compress "deflate" set decompressedBytes [new_CkByteData] set compressedBytes [new_CkByteData] set i 0 while {$i < $numBlocks} { set success [CkFileAccess_ReadBlock $facSrc $i $blockSize $compressedBytes] if {$i == 0} then { set success [CkCompression_BeginDecompressBytes $compress $compressedBytes $decompressedBytes] } else { set success [CkCompression_MoreDecompressBytes $compress $compressedBytes $decompressedBytes] } CkFileAccess_FileWrite $facDest $decompressedBytes set i [expr $i + 1] } # At the very end, flush any remaining decompressed bytes, if any. set success [CkCompression_EndDecompressBytes $compress $decompressedBytes] CkFileAccess_FileWrite $facDest $decompressedBytes CkFileAccess_FileClose $facSrc CkFileAccess_FileClose $facDest puts "Finished decompressing file." delete_CkFileAccess $facSrc delete_CkFileAccess $facDest delete_CkCompression $compress delete_CkByteData $decompressedBytes delete_CkByteData $compressedBytes |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.