![]() |
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
(Unicode C) 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.
#include <C_CkGzipW.h> #include <C_CkBinDataW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { BOOL success; HCkGzipW gzip; HCkBinDataW bd; HCkJsonObjectW json; const wchar_t *filename; const wchar_t *comment; const wchar_t *extraData; success = FALSE; // This example demonstrates how to retrieve metadata from Gzip data // stored in a BinData object. gzip = CkGzipW_Create(); bd = CkBinDataW_Create(); json = CkJsonObjectW_Create(); // Load a Gzip file into BinData: success = CkBinDataW_LoadFile(bd,L"example.txt.gz"); if (success == FALSE) { wprintf(L"%s\n",CkBinDataW_lastErrorText(bd)); CkGzipW_Dispose(gzip); CkBinDataW_Dispose(bd); CkJsonObjectW_Dispose(json); return; } // Get the metadata information from the in-memory Gzip data: success = CkGzipW_GetGzipInfoBd(gzip,bd,json); if (success == FALSE) { wprintf(L"%s\n",CkGzipW_lastErrorText(gzip)); CkGzipW_Dispose(gzip); CkBinDataW_Dispose(bd); CkJsonObjectW_Dispose(json); return; } // Output the JSON containing metadata: wprintf(L"Gzip metadata JSON:\n"); wprintf(L"%s\n",CkJsonObjectW_emit(json)); // Access individual fields only if they exist: if (CkJsonObjectW_HasMember(json,L"filename") == TRUE) { filename = CkJsonObjectW_stringOf(json,L"filename"); wprintf(L"Filename: %s\n",filename); } if (CkJsonObjectW_HasMember(json,L"comment") == TRUE) { comment = CkJsonObjectW_stringOf(json,L"comment"); wprintf(L"Comment: %s\n",comment); } if (CkJsonObjectW_HasMember(json,L"extraData") == TRUE) { extraData = CkJsonObjectW_stringOf(json,L"extraData"); wprintf(L"ExtraData (Base64): %s\n",extraData); } CkGzipW_Dispose(gzip); CkBinDataW_Dispose(bd); CkJsonObjectW_Dispose(json); } |
||||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.