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
(PowerBuilder) Decompress Large Binary File in BlocksDecompresses a large binary file in blocks. This example uses BeginDecompressBytes, MoreDecompressBytes, and EndDecompressBytes.
integer li_rc oleobject loo_FacSrc oleobject loo_FacDest integer li_Success integer li_BlockSize integer li_NumBlocks oleobject loo_Compress integer i // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_FacSrc = create oleobject // Use "Chilkat_9_5_0.FileAccess" for versions of Chilkat < 10.0.0 li_rc = loo_FacSrc.ConnectToNewObject("Chilkat.FileAccess") if li_rc < 0 then destroy loo_FacSrc MessageBox("Error","Connecting to COM object failed") return end if loo_FacDest = create oleobject // Use "Chilkat_9_5_0.FileAccess" for versions of Chilkat < 10.0.0 li_rc = loo_FacDest.ConnectToNewObject("Chilkat.FileAccess") // Open a previously compressed file for decompressing. // See Compress Large File in Blocks li_Success = loo_FacSrc.OpenForRead("qa_data/bmp/compressedBmp.dat") if li_Success <> 1 then Write-Debug loo_FacSrc.LastErrorText destroy loo_FacSrc destroy loo_FacDest return end if // If we compress in 32K chunks, find out how many blocks there will be. li_BlockSize = 32768 li_NumBlocks = loo_FacSrc.GetNumBlocks(li_BlockSize) // Open an output file for the decompressed data. li_Success = loo_FacDest.OpenForWrite("qa_output/decompressed.bmp") if li_Success <> 1 then Write-Debug loo_FacDest.LastErrorText destroy loo_FacSrc destroy loo_FacDest return end if loo_Compress = create oleobject // Use "Chilkat_9_5_0.Compression" for versions of Chilkat < 10.0.0 li_rc = loo_Compress.ConnectToNewObject("Chilkat.Compression") loo_Compress.Algorithm = "deflate" i = 0 do while i < li_NumBlocks loo_CompressedBytes = loo_FacSrc.ReadBlock(i,li_BlockSize) if i = 0 then loo_DecompressedBytes = loo_Compress.BeginDecompressBytes(loo_CompressedBytes) else loo_DecompressedBytes = loo_Compress.MoreDecompressBytes(loo_CompressedBytes) end if loo_FacDest.FileWrite(loo_DecompressedBytes) i = i + 1 loop // At the very end, flush any remaining decompressed bytes, if any. loo_DecompressedBytes = loo_Compress.EndDecompressBytes() loo_FacDest.FileWrite(loo_DecompressedBytes) loo_FacSrc.FileClose() loo_FacDest.FileClose() Write-Debug "Finished decompressing file." destroy loo_FacSrc destroy loo_FacDest destroy loo_Compress |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.