(PureBasic) Unzip a .zip Archive
Demonstrates how to open a .zip archive and unzip. The Unzip method extracts the files and directories from a .zip archive and recreates the directory tree rooted at the directory path passed to Unzip.
IncludeFile "CkZip.pb"
Procedure ChilkatExample()
; This example requires 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.i = CkZip::ckOpenZip(zip,"my_files.zip")
If success <> 1
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
unzipCount.i
; Returns the number of files and directories unzipped.
; Unzips to /my_files, re-creating the directory tree
; from the .zip.
unzipCount = CkZip::ckUnzip(zip,"/my_files")
If unzipCount < 0
Debug CkZip::ckLastErrorText(zip)
Else
Debug "Success!"
EndIf
CkZip::ckDispose(zip)
ProcedureReturn
EndProcedure
|