![]() |
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
(PureBasic) Retrieve Metadata from a Gzip FileSee more Gzip ExamplesThis example demonstrates how to use the The method reads the Gzip header and extracts any available metadata, including the embedded filename, comment, and optional extra data. The extracted information is returned in a Because these fields are optional, the example checks for the existence of each JSON member using Note: This example requires Chilkat v11.5.0 or greater.
IncludeFile "CkGzip.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() success.i = 0 ; This example demonstrates how to retrieve metadata embedded in a Gzip file. gzip.i = CkGzip::ckCreate() If gzip.i = 0 Debug "Failed to create object." ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; The Gzip file to examine: gzPath.s = "example.txt.gz" ; Get the metadata information: success = CkGzip::ckGetGzipInfo(gzip,gzPath,json) If success = 0 Debug CkGzip::ckLastErrorText(gzip) CkGzip::ckDispose(gzip) CkJsonObject::ckDispose(json) ProcedureReturn EndIf ; Output the JSON containing metadata: Debug "Gzip metadata JSON:" Debug CkJsonObject::ckEmit(json) ; Access individual fields only if they exist: If CkJsonObject::ckHasMember(json,"filename") = 1 filename.s = CkJsonObject::ckStringOf(json,"filename") Debug "Filename: " + filename EndIf If CkJsonObject::ckHasMember(json,"comment") = 1 comment.s = CkJsonObject::ckStringOf(json,"comment") Debug "Comment: " + comment EndIf If CkJsonObject::ckHasMember(json,"extraData") = 1 extraData.s = CkJsonObject::ckStringOf(json,"extraData") Debug "ExtraData (Base64): " + extraData EndIf CkGzip::ckDispose(gzip) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.