Extensions.ZipHandling.UnZipFile

From emotive
Jump to navigation Jump to search

Classification

Name UnZipFile
Short Description Decompresses the ZIP file
Class Action
Extension OTX ZipHandling extension
Group ZipHandling related Actions
Exceptions FileAlreadyExistsException
FileNotFoundException
ZipFormatException
Checker Rules ZipFiles_Chk001
Standard Compliant Yes

OTL Syntax

ZipHandling.UnZipFile(StringTerm source, StringTerm target, ListTerm extensions, BooleanTerm override);

Description

Decompresses the ZIP file denoted by the given source path. The source path must point to a valid ZIP container (the file extension need not to be .zip).
It is possible to control which files to extract by passing in a pattern. Only the files that match the pattern will be extracted (including the folder structures they are contained in). Furthermore it is possible to specify whether any existing target files will be overridden or not. If the corresponding flag is set to TRUE, then any existing target file will be silently overridden.
Otherwise, if the flag is set to FALSE and a to-be-written file in the target location already exists, an exception is thrown.

Properties

Name Data Type Class Default Cardinality Description
Source String Term - [1..1] Contains the path to the to-be-decompressed ZIP file. The path will be a URI, relative to the OTX_HOME directory. If the ZIP file denoted by this path does not exist, is not accessible or is not a valid ZIP container, an exception is thrown.
Target String Term - [1..1] Contains the path to the to extract the contents of the ZIP container to.

The path will be a URI, relative to the OTX_HOME directory. If the target location denoted by this path contains any file that is to be extracted and the override flag is not set or set to FALSE, then an exception is thrown.

Extensions List Term - [0..1] The extensions element is a List of Strings. It contains a list of file extension strings. Only files, that have the given file extension (e.g. "txt": files ending with .txt) will be unpacked from the zip file.

This element is optional and if omitted, no filtering is performed, unpacking any file with any file extension. In case, that files without an extension will be unzipped an empty string is used.
It is possible to provide strings that contain wildcard characters. These are used as placeholders for arbitrary characters. The characters are:
⎯ '*' (asterisk) for an arbitrary amount [0..*] of consecutive characters.
⎯ '?' (question mark) for exactly one arbitrary character.
EXAMPLE:
With the extension of ["log*"] the following files will match (amongst others):
⎯ File.log
⎯ File.log1
⎯ File.log_02
⎯ File.log.01
The following file will not match:
⎯ File.3log
⎯ File.lg.log
⎯ File.zip
EXAMPLE:
With the extensions of ["t?t"] the following files will match (amongst others):
⎯ File.txt
⎯ File.tut
⎯ File.t1t
The following files will not match:
⎯ File.tt
⎯ File.text
⎯ File.log
IMPORTANT — Case sensitivity is platform dependent and may very depending on the underlying system. It might therefore be necessary to provide a list with upper case and lower case variants of the same extension (e.g. "txt" and "TXT")

Override Boolean Term - [0..1] Determines whether any already existing target file will be overridden or not.

If the flag evaluates to TRUE, an existing target file will be silently overridden.
If it evaluates to FALSE, an existing target file will cause an exception to be thrown.
If the flag is omitted, it defaults to FALSE.

OTL Examples

/// Local Declarations

/// Flow

ZipHandling.UnZipFile("file:///D:/FileZipped.zip", "file:///D:/FolderUnZipped", {"part*"}, true);

See also

ZipFile