OTX Reference  
OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile Class Reference

Compresses the file or folder More...

Inheritance diagram for OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile:
Inheritance graph

Public Attributes

BooleanTerm _override
 Determines whether an already existing target file will be overridden or not. More...
 
BooleanTerm append
 Zipped sources shall be appended to an existing ZIP file if flag is true or replacing that ZIP file with a new one if flag is true More...
 
ListTerm extensions
 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. More...
 
StringTerm source
 Contains the path to the to-be-zipped file or folder More...
 
StringTerm target
 Contains the path to the target ZIP file More...
 
- Public Attributes inherited from OpenTestSystem.Otx.Core.Actions.ActionRealisation
OtxLink validFor
 Validity of ActionRealisation. More...
 

Detailed Description

Compresses the file or folder

The ZipFile activity to 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.

Exceptions
Exceptions.FileAlreadyExistsException
Exceptions.FileNotFoundException
Checker rules
CheckerRule.ZipFiles_Chk002 - type-safe ZipFile

Syntax
ZipHandling.ZipFile(StringTerm source, StringTerm target, ListTerm extensions, BooleanTerm append, BooleanTerm override);
StringTerm target
Contains the path to the target ZIP file
Definition: ZipHandling.cs:211
BooleanTerm append
Zipped sources shall be appended to an existing ZIP file if flag is true or replacing that ZIP file w...
Definition: ZipHandling.cs:291
ListTerm extensions
Contains a list of file extension strings. Only files, that have the given file extension (e....
Definition: ZipHandling.cs:273
StringTerm source
Contains the path to the to-be-zipped file or folder
Definition: ZipHandling.cs:195
Examples
// Local Declarations
// Flow
ZipHandling.ZipFile("file:///D:/FolderUnZipped", "file:///D:/FileZipped.zip", {"t?t"}, false, true);

Member Data Documentation

◆ _override

BooleanTerm OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile._override

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. 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. If the append flag is present and evaluates to TRUE, then the override flag concerns overriding files in the target ZIP file.This means, that the above mentioned rules are applied to the contents of the target ZIP file, possibly throwing a FileAlreadyExistsException, if any of the source files is already stored in the denoted ZIP file. In case an exception occurs the existing zip file will be unchanged.

◆ append

BooleanTerm OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile.append

Zipped sources shall be appended to an existing ZIP file if flag is true or replacing that ZIP file with a new one if flag is true

If this flag is omitted, it defaults to FALSE. If the target ZIP file does not exist and the append flag is provided and resolves to TRUE, a FileNotFoundException is thrown.

◆ extensions

ListTerm OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile.extensions

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. 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 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
    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
    IMPORTANT - Case sensitivity is platform dependent and may vary 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").

◆ source

StringTerm OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile.source

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

StringTerm OpenTestSystem.Otx.Extensions.ZipHandling.Actions.ZipFile.target

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.