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
(DataFlex) Unzip Binary File to StreamDemonstrates how to unzip a large binary file to a stream to allow the application to process the uncompressed bytes chunk by chunk. Note: This example requires Chilkat v9.5.0.67 or greater.
Use ChilkatAx-win32.pkg Procedure Test Handle hoZip Boolean iSuccess Variant vEntry Handle hoEntry Variant vDataStream Handle hoDataStream Variant vUnzipTask Handle hoUnzipTask Handle hoFac Variant vBd Handle hoBd String sTemp1 Boolean bTemp1 // This requires the Chilkat Zip API to have been previously unlocked. // See Unlock Chilkat Zip for sample code. Get Create (RefClass(cComChilkatZip)) To hoZip If (Not(IsComObjectCreated(hoZip))) Begin Send CreateComObject of hoZip End // First open a .zip. Get ComOpenZip Of hoZip "qa_data/zips/big.zip" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // Get the entry to be unzipped to a stream.. Get ComGetEntryByIndex Of hoZip 0 To vEntry If (IsComObject(vEntry)) Begin Get Create (RefClass(cComChilkatZipEntry)) To hoEntry Set pvComObject Of hoEntry To vEntry End Get ComLastMethodSuccess Of hoZip To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStream)) To hoDataStream If (Not(IsComObjectCreated(hoDataStream))) Begin Send CreateComObject of hoDataStream End Get pvComObject of hoDataStream to vDataStream Get ComUnzipToStreamAsync Of hoEntry vDataStream To vUnzipTask If (IsComObject(vUnzipTask)) Begin Get Create (RefClass(cComChilkatTask)) To hoUnzipTask Set pvComObject Of hoUnzipTask To vUnzipTask End Get ComLastMethodSuccess Of hoEntry To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoEntry To sTemp1 Showln sTemp1 Send Destroy of hoEntry Procedure_Return End // Start the background unzip thread. Get ComRun Of hoUnzipTask To iSuccess // We'll read the uncompressed data chunk-by-chunk and write to an output file. Get Create (RefClass(cComCkFileAccess)) To hoFac If (Not(IsComObjectCreated(hoFac))) Begin Send CreateComObject of hoFac End Get ComOpenForWrite Of hoFac "qa_output/out.dat" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoFac To sTemp1 Showln sTemp1 Send Destroy of hoEntry Procedure_Return End // Read the stream. (this is reading the unzipped file data) Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End While ((ComEndOfStream(hoDataStream)) <> True) // Get the next chunk of decompressed bytes. Get pvComObject of hoBd to vBd Get ComReadBd Of hoDataStream vBd To iSuccess // Do something with it.. // In this simple example, we'll just write to the file. Get pvComObject of hoBd to vBd Get ComFileWriteBd Of hoFac vBd 0 0 To iSuccess // Clear for the next read. Get ComClear Of hoBd To iSuccess Loop Send ComFileClose To hoFac Send Destroy of hoEntry Send Destroy of hoUnzipTask Showln "Success." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.