TrFile_GetZipInfo (function reference)

By January 1, 2021January 26th, 2021Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetZipInfo
Troi File Plug-in for FileMaker Pro

TrFile_GetZipInfo

Get information from a ZIP file.

SyntaxFunction badge

TrFile_GetZipInfo ( switches ; sourceZipFilePath )

Parameters

switches modifies the behavior of the function
sourceZipFilePath the path to the ZIP file

Switches

The switches parameter currently has one possible value:

-ItemList (default) return the list of files and folders in the ZIP file

You can also add this switch:

-SkipHiddenMacOSXItems don’t list items which are in a __MACOSX folder in the ZIP

macOS stores extra info and resource forks in these __MACOSX folders

Returned Result

Data type returned

Text

Result

a list of files and folders in the ZIP file.

The result can also be an error code. Returned error codes can be:

$$-43 fnfErr ZIP file not found

Originated in

Troi File Plug-in 8.5

Compatibility

FileMaker Pro 16 to 19

Considerations

Each item is returned on a separate line: all items (including the last item) are followed by a return character.

Example

Set Field [ $ZIP_Items ; TrFile_GetZipInfo ( "-ItemList" ; "D:\myZIP2016.zip" ) ]

This will list what is stored in the ZIP file. The result will be for example:
my report/
my report/fiscal.xls
my report/illustration.jpg
my report/extra data/
my report/extra data/note.txt

In this list you see that the folder “my report” contains 2 files and a subfolder “extra data”. Folders end with a slash and subfolders are also separated with a slash.

Example 2

We assume that in your FileMaker file the following fields are defined and filled with a path to the source ZIP file:

	this::ZIPsourcePath 	may contain something like "MacHD:Users:kip:bigtext.zip" 
	this::ZIPlist 		the result will be stored here

This example will first set the variable from the path stored in the first field and then list the items of the ZIP file.
In a script add the following steps:

# Initialize: copy the field into a variable first:
Set Variable [ $SourcePath ; this::ZIPsourcePath ]
# Now get the item list :
Set Variable [ $ItemList ; TrFile_GetZipInfo ( "-ItemList" ; $SourcePath ) ] 
If [ Left ( $ItemList ; 2 ) <> "$$"
	Set Field [ this::ZIPlist ; $ItemList ]
Else
	Show Custom Dialog [ "An error occurred" ; "OK" ]
Endif

Used in example file

ZIPAndUnZIP.fmp12

Related functionsFunction badge

TrFile_CreateZip
TrFile_UnZip

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 19 –> TrFile_GetZipInfo (filep4305) 2021-0126 11:27:48