UnzipFile
UnzipFile [ /O[=mode] /PASS=passwordStr /PIN=inputPathName /POUT=outputPathName /Z[=z] ] inputFileStr, outputFolderStr
The UnzipFile operation unzips a file and saves the contents of the file in the specified output directory.
If you specify /O=2 for an output directory that already exists, all previous contents of the directory are deleted.
The UnzipFile operation was added in Igor Pro 9.00.
Input File Parameter
inputFileStr specifies the zip file to unzip. The file name extension is not important but the file must be a zip file.
inputFileStr can be a full path to the file, in which case /PIN=inputPathName is not needed, a partial path relative to the directory associated with inputPathName, or the name of a file in the folder associated with inputPathName.
If you use a full or partial path for inputFileStr, see Path Separators for details on forming the path.
Output Folder Parameter
outputFolderStr specifies the directory into which the contents of the zip file will be extracted.
outputFolderStr can be a full path to the directory, in which case /POUT=outputPathName is not needed, a partial path relative to the directory associated with outputPathName, or an empty string in which case the directory specified by /POUT=outputPathName is used for the output directory.
If outputFolderStr is an empty string, the /POUT flag specifies the output directory.
If outputFolderStr is not an empty string, it must end with a directory name and not a path separator such as colon or backslash.
If you use a full or partial path for outputFolderStr, see Path Separators for details on forming the path.
If the output directory does not exist, it is created automatically.
Flags
| /O[=mode] | Controls whether the contents of the output directory are overwritten. | ||||||||||
| |||||||||||
caution If you specify /O=2 for an output directory that already exists, all previous contents of the directory are deleted. | |||||||||||
| /PASS=passwordStr | Specifies the password for a password-protected zip file. Only the older ZipCrypto "encryption" algorithm is supported, not the newer and much more secure AES-256 algorithm. | ||||||||||
| /PIN=inputPathName | Contributes to the specification of the input zip file to be extracted. inputPathName is the name of an existing symbolic path. See Input File Parameter above for details. | ||||||||||
| /POUT=outputPathName | Contributes to the specification of the output directory into which the zip file's contents will be extracted. outputPathName is the name of an existing symbolic path. See Output Folder Parameter above for details. | ||||||||||
| /Z[=z] | Suppress error generation. | ||||||||||
| |||||||||||
| /Z alone has the same effect as /Z=1. | |||||||||||
Output Variables
UnzipFile sets the following output variables:
| V_flag | V_flag is set to zero if the operation succeeds or to a non-zero Igor error code if it fails. You can use V_flag along with the /Z flag to handle errors and prevent them from halting procedure execution. | |
| S_outputFullPath | A string containing the full path to the output directory. If the operation fails, S_outputFullPath is set to "". | |
Limitations
File and directory names within a zip file that contain non-ASCII characters may not have the correct names after unzipping.
The created and modified timestamps of a file are reconstructed with limited range and precision. Some zip files store these timestamps in an alternative format that allows for greater precision and range, but the current unzip algorithm does not support this newer format.
Examples
// Unzip a file using full paths
String zipFileString = "C:Users:Fred:Documents:Test.zip"
String outputPathString = "C:Users:Fred:Documents:Extracted"
UnzipFile zipFileString, outputPathString
// Unzip a file using symbolic paths
String zipFileName = "Test.zip"
String outputFolderName = "" // Unzip to folder specified by /POUT
UnzipFile/PIN=home/POUT=home zipFileName, outputFolderName