Extracts a file from a zip file into a variable.
Syntax
Data = SRP_Zip_ExtractFile(ZipHandle, Index, Password)
Returns
The extracted file's data, or "" if the file was empty or if there was an error.
Parameters
Ziphandle Handle to an opened zip file.
Index Index of the file to extract.
Password Extracted file's security password, if any. Optional.
Remarks
Call this routine to extract a file into a variable. The value of Index can the value returned by SRP_Zip_FindFile or the same index used to reference the file in the value returned by SRP_Zip_GetFileList. The Password parameter is necessary for password protected zip files. Note that in most zip files, the password is the same throughout, but it is possible to protect each file with its own password.
Examples
// extract all files and save to a table (assuming table was previously opened) hZip = SRP_Zip_Open("C:\MyFile.zip") If hZip EQ 0 then Call Msg(@Window, SRP_Zip_GetLastError()) end else FileList = SRP_Zip_GetFileList(hZip) NumFiles = Count(FileList, @FM) + (FileList NE "") For i = 1 to NumFiles Data = SRP_Zip_ExtractFile(hZip, i) Write Data to hTable, FileList then NULL Next i SRP_Zip_Close(hZip) end
// extract and save a single known file to a table (assuming table was previously opened) hZip = SRP_Zip_Open("C:\MyFile.zip") If hZip EQ 0 then Call Msg(@Window, SRP_Zip_GetLastError()) end else FileIndex = SRP_Zip_FindFile(hZip, "MyImage.BMP") If FileIndex NE 0 then Data = SRP_Zip_ExtractFile(hZip, FileIndex) Write Data to hTable, "MyImage.BMP" then NULL end SRP_Zip_Close(hZip) end