Skip to main content

TrFile_GetZipInfo (function reference)

By June 1, 2024June 4th, 2024Online 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

Switches can be empty or this:

-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

You can also add one of these encoding switches (Windows only), which determine how the filenames in the ZIP file bytes are interpreted.

-Encoding=ASCII_DOS
-Encoding=ASCII_Windows (Windows ANSI)
-Encoding=ASCII_Mac (Mac Roman)
-Encoding=ISO_8859_1 (Windows Latin-1)
-Encoding=UTF8

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 17 to FileMaker Pro 21 (2024)

Considerations

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

Version 13.0 added the -Encoding=xxx switches (on Windows only). The filenames in the ZIP file will be interpreted according to this switch. This is useful if the ZIP was created using a non-standard filename encoding. On macOS the encoding switch is currently ignored.

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 17 to 2024 –> TrFile_GetZipInfo (filep4305) 2024-0604 19:21:59