Blog Entry Updated (10/02/2006 12:27 AM):
Corrected the signature for UnzipAFileInfo function. – Thanks Malcolm Greene.
Bo Durban Rocks!
Yesterday Bo (owner of Moxie Data, Inc.) posted a comment on my previous blog entry regarding the VFP Compression FLL. He said he would like “some type of information about the zipped files…”. Well, I messaged him the structure of the file information that I needed to work with and challenged him to produce a FLL function that could consume that structure and create a VFP array from it. He took the bait (he can’t resist a challenge) and in less than 2 hours I had the source to a Visual C++ function that fit the bill. I was impressed with the speed at which Bo had produced the function as well as some of the technical hurdles regarding datetime data types that he had surmounted.
New functions to retrieve file information
My job (after receiving the code from Bo) was simple by comparison and in less than 10 minutes I had his code implemented in the FLL. I wrapped it with a couple of new functions, UnzipGetFileInfo and UnzipGetFileInfoByIndex. A new download as well as some sample VFP code for using the new functions and documentation are provided below. For complete documentation of the vfpcompression.fll see my previous blog entry.
VFP Compression Update:
VFPCompression FLL Download (33 KB approx.)
Sample VFP Code
*!* CLEAR
*!* SET LIBRARY TO LOCFILE(“vfpcompression.fll”)
*!* UnzipOpen(“C:\MyZipFile.zip”)
*!* UnzipGotoTopFile()
*!* UnzipAFileInfo(“laTestArray”)
*!* UnzipClose()
*!* SET LIBRARY TO
*!* showfileinfo(@laTestArray)
*!* ?
CLEAR
SET LIBRARY TO LOCFILE(“vfpcompression.fll”)
UnzipOpen(“C:\MyZipFile.zip”)
UnzipAFileInfoByIndex(“laTestArray”,2)
UnzipClose()
SET LIBRARY TO
showfileinfo(@laTestArray)
FUNCTION showfileinfo(aFileInfo)
LOCAL lnCounter
LOCAL ARRAY aCaptions(13)
aCaptions(1) = “File Name”
aCaptions(2) = “Comment”
aCaptions(3) = “Version”
aCaptions(4) = “Version Needed”
aCaptions(5) = “Flags”
aCaptions(6) = “Compression Method”
aCaptions(7) = “DateTime”
aCaptions(8) = “CRC”
aCaptions(9) = “Compressed Size”
aCaptions(10) = “Uncompressed Size”
aCaptions(11) = “Internal Attribute”
aCaptions(12) = “External Attribute”
aCaptions(13) = “Folder”
FOR lncounter = 1 TO 13
?aCaptions(lnCounter)
?aFileInfo(lnCounter)
?TYPE(“aFileInfo(lnCounter)”)
ENDFOR
ENDFUNC
Additional Documentation
Function UnzipAFileInfoByIndex()
Signature: UnzipAFileInfoByIndex(cArrayName, nIndex)
Parameters:
cArrayName – Name of the VFP array to store the file information in. This array will be created if it doesn’t already exist.
nIndex – The index number of the file you want to return information about.
Return Value:
Logical – returns .T. if successful or .F. if the operation has failed.
Creates an array with 13 rows (elements) in it. The rows contain various pieces of information regarding the file that is held in the zipped file at nIndex. The following table describes the contents and data type of each row in the array:
Row | Array Content | Data Type |
1 | File Name | Character |
2 | Comment | Character |
3 | Version | Numeric |
4 | Version Needed | Numeric |
5 | Flags | Numeric |
6 | Compression Method | Numeric |
7 | DOS Date | Datetime |
8 | CRC | Numeric |
9 | Compressed Size | Numeric |
10 | Uncompressed Size | Numeric |
11 | Internal Attribute | Numeric |
12 | External Attribute | Numeric |
13 | Folder | Logical |
Remarks:
The array that is created will have whatever name was specified by cArrayName. Should the array already exist it will be released and recreated. UnzipAFileInfoByIndex() is used between calls to UnzipOpen() and UnzipClose() to show information about a particular file. The file is referred to by the position it physically holds in the contents of the open zip file. You can think of the contents of a zip file as records in a table. In this sense the UnzipAFileInfoByIndex function is used to refer to and retrieve information about a particular record number in the zip file.
Function UnzipAFileInfo()
Signature: UnzipAFileInfo(cArrayName)
Parameters:
cArrayName – Name of the VFP array to store the file information in. This array will be created if it doesn’t already exist.
Return Value:
Logical – returns .T. if successful or .F. if the operation has failed.
Creates an array with 13 rows (elements) in it. The rows contain various pieces of information regarding the currently selected file in the zip. The following table describes the contents and data type of each row in the array:
Row | Array Content | Data Type |
1 | File Name | Character |
2 | Comment | Character |
3 | Version | Numeric |
4 | Version Needed | Numeric |
5 | Flags | Numeric |
6 | Compression Method | Numeric |
7 | DOS Date | Datetime |
8 | CRC | Numeric |
9 | Compressed Size | Numeric |
10 | Uncompressed Size | Numeric |
11 | Internal Attribute | Numeric |
12 | External Attribute | Numeric |
13 | Folder | Logical |
Remarks:
The array that is created will have whatever name was specified by cArrayName. Should the array already exist it will be released and recreated. UnzipAFileInfo() is used between calls to UnzipOpen() and UnzipClose() to show information about a particular file. Use the UnzipAFileInfo function in conjunction with UnzipGotoTopFile, UnzipGotoNextFile, UnzipGotoFileByName, and UnzipGotoFileByIndex functions to return information regarding a particular file contained in the open zip file. You can think of the contents of a zip file as records in a table. In this sense the UnzipAFileInfo function is used to refer to and retrieve information about the record that the record pointer is currently on within the zip file.
I got here looking for the documentation.
Very nice alternative!!
Thank you!!
Hasta luego.
Hernán Cano
Medellín, Antioquia
Colombia