![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Add Custom Extra Data to a Gzip FileThis example demonstrates how to use the The hex string represents the raw bytes to embed in the Gzip metadata. When a compression method is called, this data is included in the Gzip header. The example also shows how to retrieve the metadata using
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoGzip Variant vJson Handle hoJson String sInputFile String sOutputFile String sTemp1 Move False To iSuccess // This example demonstrates how to include custom extra data // in the Gzip header when compressing. // The extra data is provided as a hex-encoded string. Get Create (RefClass(cComChilkatGzip)) To hoGzip If (Not(IsComObjectCreated(hoGzip))) Begin Send CreateComObject of hoGzip End Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End // Set extra data using a hex string. // This example represents 4 bytes: 00 01 02 03 Get ComSetExtraData Of hoGzip "00010203" "hex" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoGzip To sTemp1 Showln sTemp1 Procedure_Return End // Compress a file so the extra data is embedded in the Gzip header: Move "example.txt" To sInputFile Move "example.txt.gz" To sOutputFile Get ComCompressFile Of hoGzip sInputFile sOutputFile To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoGzip To sTemp1 Showln sTemp1 Procedure_Return End Showln "Gzip file created with extra data." // (Optional) Retrieve the metadata to verify: Get pvComObject of hoJson to vJson Get ComGetGzipInfo Of hoGzip sOutputFile vJson To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoGzip To sTemp1 Showln sTemp1 Procedure_Return End Showln "Metadata JSON:" Get ComEmit Of hoJson To sTemp1 Showln sTemp1 End_Procedure |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.