Extensions.ZipHandling.ZipFile
Classification
Name | ZipFile |
Short Description | Compresses the file or folder |
Class | Action |
Extension | OTX ZipHandling extension |
Group | ZipHandling related Actions |
Exceptions | FileAlreadyExistsException FileNotFoundException |
Checker Rules | ZipFiles_Chk002 |
Standard Compliant | Yes |
OTL Syntax
ZipHandling.ZipFile(StringTerm source, StringTerm target, ListTerm extensions, BooleanTerm append, BooleanTerm override);
Description
Compresses the file or folder denoted by the given source path. If the path points to a single file, only that file will be stored in the target file. If the path points to a folder, the folder and all its contents (files and subfolders in arbitrary depth) will be stored in the target file. In the case of a folder, that folder will be the root element in the target file.
It is possible to control which files to add by passing in a list of allowed file extensions. Only the files that match one of the given file extension strings will be added (including the folder structures they are contained in).
Furthermore it is possible to specify whether an existing target file will be overridden or not. Depending on whether the source(s) will be appended to an existing ZIP file, a flag controls whether or not the corresponding flag is set to TRUE, then any existing ZIP file will be silently overridden. Otherwise, if the flag is set to FALSE and the denoted target file already exists, an exception is thrown.
Properties
Name | Data Type | Class | Default | Cardinality | Description |
Source | String | - | - | [1..1] | Contains the path to the to-be-zipped file or folder. The path will be a URI, relative to the OTX_HOME directory. If the file or folder denoted by this path does not exist or is not accessible, an exception is thrown. |
Target | String | - | - | [1..1] | Contains the path to the target ZIP file. The path will be a URI, relative to the OTX_HOME directory. If the file denoted by this path already exists and the override flag is not set or set to FALSE, then an exception is thrown. Also if the file already exists and cannot be overridden, or if it cannot be created at the given location, an exception is thrown. |
Extensions | List | - | - | [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 stored in the zip file. This element is optional and if omitted, no filtering is performed, accepting any file with any file extension. In case, that files without an extension will be zipped an empty string is used. |
Append | Boolean | - | - | [0..1] | If this flag is set to TRUE, then the to be zipped sources will be appended to an existing ZIP file, instead of replacing that ZIP file with a new one. If this flag is omitted, it defaults to FALSE. |
Override | Boolean | - | - | [0..1] | Determines whether an already existing target file will be overridden or not.
If the flag evaluates to TRUE, an existing target file will be silently overridden. |
OTL Examples
/// Global Declarations
public procedure main()
{
/// Local Declarations
/// Flow
ZipHandling.ZipFile("file:///D:/FolderUnZipped", "file:///D:/FileZipped.zip", {"t?t"}, false, true);
}