![]() |
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
(Delphi DLL) Retrieve Metadata from Gzip Data in Memory (BinData)This example demonstrates how to use the The Gzip data is first loaded into the The metadata is returned in a Note: This example requires Chilkat v11.5.0 or greater.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Gzip, BinData, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var success: Boolean; gzip: HCkGzip; bd: HCkBinData; json: HCkJsonObject; filename: PWideChar; comment: PWideChar; extraData: PWideChar; begin success := False; // This example demonstrates how to retrieve metadata from Gzip data // stored in a BinData object. gzip := CkGzip_Create(); bd := CkBinData_Create(); json := CkJsonObject_Create(); // Load a Gzip file into BinData: success := CkBinData_LoadFile(bd,'example.txt.gz'); if (success = False) then begin Memo1.Lines.Add(CkBinData__lastErrorText(bd)); Exit; end; // Get the metadata information from the in-memory Gzip data: success := CkGzip_GetGzipInfoBd(gzip,bd,json); if (success = False) then begin Memo1.Lines.Add(CkGzip__lastErrorText(gzip)); Exit; end; // Output the JSON containing metadata: Memo1.Lines.Add('Gzip metadata JSON:'); Memo1.Lines.Add(CkJsonObject__emit(json)); // Access individual fields only if they exist: if (CkJsonObject_HasMember(json,'filename') = True) then begin filename := CkJsonObject__stringOf(json,'filename'); Memo1.Lines.Add('Filename: ' + filename); end; if (CkJsonObject_HasMember(json,'comment') = True) then begin comment := CkJsonObject__stringOf(json,'comment'); Memo1.Lines.Add('Comment: ' + comment); end; if (CkJsonObject_HasMember(json,'extraData') = True) then begin extraData := CkJsonObject__stringOf(json,'extraData'); Memo1.Lines.Add('ExtraData (Base64): ' + extraData); end; CkGzip_Dispose(gzip); CkBinData_Dispose(bd); CkJsonObject_Dispose(json); end; |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.