PureBasic Requires Chilkat v11.0.0+
PureBasic
Unzip Files to Byte Array
See more Zip Examples
Demonstrates how to unzip each file contained in a .zip to an in-memory byte array.Chilkat PureBasic Downloads
IncludeFile "CkZip.pb"
IncludeFile "CkZipEntry.pb"
Procedure ChilkatExample()
success.i = 0
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
zip.i = CkZip::ckCreate()
If zip.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkZip::ckOpenZip(zip,"qa_data/zips/test.zip")
If success = 0
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
; Iterate of each entry in the zip.
; An entry can be a file or directory entry. For each file, unzip to a byte array.
numEntries.i = CkZip::ckNumEntries(zip)
Debug "NumEntries = " + Str(numEntries)
entry.i = CkZipEntry::ckCreate()
If entry.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
i.i = 0
While i < numEntries
CkZip::ckEntryAt(zip,i,entry)
If CkZipEntry::ckIsDirectory(entry) = 0
ERROR - PureBasic is an array language = CkZipEntry::ckInflate(entry)
; Do whatever you wish with the file data...
EndIf
i = i + 1
Wend
CkZip::ckCloseZip(zip)
Debug "Finished."
CkZip::ckDispose(zip)
CkZipEntry::ckDispose(entry)
ProcedureReturn
EndProcedure