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
(Lianja) Decompress Large Binary File in BlocksDecompresses a large binary file in blocks. This example uses BeginDecompressBytes, MoreDecompressBytes, and EndDecompressBytes.
// This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loFacSrc = createobject("CkFileAccess") loFacDest = createobject("CkFileAccess") // Open a previously compressed file for decompressing. // See Compress Large File in Blocks llSuccess = loFacSrc.OpenForRead("qa_data/bmp/compressedBmp.dat") if (llSuccess <> .T.) then ? loFacSrc.LastErrorText release loFacSrc release loFacDest return endif // If we compress in 32K chunks, find out how many blocks there will be. lnBlockSize = 32768 lnNumBlocks = loFacSrc.GetNumBlocks(lnBlockSize) // Open an output file for the decompressed data. llSuccess = loFacDest.OpenForWrite("qa_output/decompressed.bmp") if (llSuccess <> .T.) then ? loFacDest.LastErrorText release loFacSrc release loFacDest return endif loCompress = createobject("CkCompression") loCompress.Algorithm = "deflate" i = 0 do while i < lnNumBlocks loCompressedBytes = loFacSrc.ReadBlock(i,lnBlockSize) if (i = 0) then loDecompressedBytes = loCompress.BeginDecompressBytes(loCompressedBytes) else loDecompressedBytes = loCompress.MoreDecompressBytes(loCompressedBytes) endif loFacDest.FileWrite(loDecompressedBytes) i = i + 1 enddo // At the very end, flush any remaining decompressed bytes, if any. loDecompressedBytes = loCompress.EndDecompressBytes() loFacDest.FileWrite(loDecompressedBytes) loFacSrc.FileClose() loFacDest.FileClose() ? "Finished decompressing file." release loFacSrc release loFacDest release loCompress |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.