![]() |
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) Unzip a ZIP Entry Directly into a BinData Object Using ZipEntry.UnzipToBdSee more Zip Examples This example demonstrates how to use the The entry contents are uncompressed entirely in memory without creating a file on disk. This is useful when:
The example opens a ZIP archive, locates a PDF entry, inflates it into a Suppose the ZIP archive contains: The entry is uncompressed directly into memory before optionally being saved to:
#include <C_CkZipW.h> #include <C_CkZipEntryW.h> #include <C_CkBinDataW.h> void ChilkatSample(void) { BOOL success; HCkZipW zip; HCkZipEntryW entry; HCkBinDataW pdfData; success = FALSE; zip = CkZipW_Create(); // Open an existing ZIP archive. success = CkZipW_OpenZip(zip,L"qa_data/zips/documents.zip"); if (success == FALSE) { wprintf(L"%s\n",CkZipW_lastErrorText(zip)); CkZipW_Dispose(zip); return; } // Locate the PDF entry within the ZIP archive. entry = CkZipEntryW_Create(); success = CkZipW_EntryOf(zip,L"docs/report.pdf",entry); if (success == FALSE) { wprintf(L"ZIP entry not found.\n"); CkZipW_CloseZip(zip); CkZipW_Dispose(zip); CkZipEntryW_Dispose(entry); return; } // ------------------------------------------------------------ // Inflate the ZIP entry directly into a BinData object. // // The uncompressed bytes are stored entirely in memory. // pdfData = CkBinDataW_Create(); success = CkZipEntryW_UnzipToBd(entry,pdfData); if (success == FALSE) { wprintf(L"%s\n",CkZipEntryW_lastErrorText(entry)); CkZipW_Dispose(zip); CkZipEntryW_Dispose(entry); CkBinDataW_Dispose(pdfData); return; } wprintf(L"Uncompressed size = %d\n",CkBinDataW_getNumBytes(pdfData)); wprintf(L"\n"); // ------------------------------------------------------------ // Optionally save the uncompressed bytes to a file. // success = CkBinDataW_WriteFile(pdfData,L"qa_output/report.pdf"); if (success == FALSE) { wprintf(L"%s\n",CkBinDataW_lastErrorText(pdfData)); CkZipW_Dispose(zip); CkZipEntryW_Dispose(entry); CkBinDataW_Dispose(pdfData); return; } CkZipW_CloseZip(zip); wprintf(L"PDF extracted successfully.\n"); CkZipW_Dispose(zip); CkZipEntryW_Dispose(entry); CkBinDataW_Dispose(pdfData); } |
||||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.