#### ZIP

#### Synopsis

    HELP:   Write a ZIP archive block-oriented
    TYPE:   OBJECT
    SYNTAX: ZIP(NET.{},NAME/FILE='str'/STREAM/DUMMY,MEMBER='str',FALLOC(),REMOVE,REMAIN,NOMKDIR,APPEND,FLUSH,ACSTIM=num,MODTIM=num,ATTRIB(),MBRATR/MEMATR(),COMENT='str',FORMAT=AUTO/Z32/Z64,ENCODE=UTF8/DOS/ASCII,NOXFLD,STREAM,PREPRO[()...],POSTPRO/PSTPRO[()...])

#### Description

This FIO.ZIP() object is used to write ZIP archives. Members are written to a ZIP archive in a block-oriented way. The FIO.ZIP() object does not compress the data by itself. You must use CNV.ZIP() or one of the compression converters to produce a compressed archive, otherwise files are stored uncompressed. Using CNV.ZIP() without any further parameters compresses archive members using the deflate compression algorithm. If you use CNV.GZP(), then a GZIP file is stored in the archive. This means that an Unzip utility will extract a still compressed GZIP file from the ZIP file. The same is valid for BZIP2 and other supported compressors.

By activating the APPEND switch, new members are appended to the ZIP file and existing members are replaced. If the REMAIN switch is enabled on append, an error occurs if a member already exists in the archive. If the APPEND switch is not used, but the REMAIN flag is set and the archive already exists, the archive is not overwritten.

Replacing a member (APPEND without REMAIN) requires a re-organization which requires a temporary file in the background. On z/OS, a memory file is allocated in the hyper space. For huge archives it is not recommended to use the overwrite feature for ZIP archives because re-organization requires considerable time and disk space.

All member names and comments are encoded in UTF-8 by default unless you specify another encoding. Currently, you can set the DOS encoding (CCSID IBM437), which is an old fashioned encoding in ZIP archives, or you can use US-ASCII as a subset of DOS and UTF-8.

Archives larger than 4 GiB or containing more than 65535 members are supported with the 64 bit ZIP archive support which some ZIP tools are not capable to read. Creation of 64 bit ZIP archives can be prevented by enforcing the 32 bit format. In that case, an error occurs when reaching one of the limits of the original ZIP format. The 64 bit format might be enforced too. If no format or 'FORMAT=AUTO' is given a backward compatible 32 bit format with 64 bit extensions for files smaller than 4 GiB are written. This format will result in a warning by 7z since version 19 and can be ignored. To prevent this warning 32 or 64 bit format must be enforced.

Writing ZIP archives requires repositioning within the file which is not supported for PDS(E) members on z/OS. Hence, ZIP archives cannot be written to a PO member. You can copy ZIP files to a PO member and read the ZIP archive from there, but you cannot write to it. You also cannot use the REMOVE switch when reading from a PO member, because this requires rewriting the ZIP archive.

With the switch STREAM the streamed version of the ZIP file format is enforced while writing. This will improve performance if only sequential I/O is required and a record oriented dataset is used. If no format is given the Zip64 format will be written in this case. With 'FORMAT=Z32' the older version of a ZIP archive can be enforced if the stream doesn't exceed 4 GiB.

With the switch NOXFLD you can deactivate the write of the FLAM private extra field to the local and directory file header. If this is used the ZIP file doesn't contain this private extension and the reconstruction of files with FLAM to the original format will fail, because not all required information are available for it.

#### Arguments

- `STRING: NAME/FILE='str'/STREAM/DUMMY - Name/URL of ZIP file to write [auto]`
  - `STREAM - Read from stdin or write to stdout`
  - `DUMMY - Read EOF or write nothing`
- `STRING: MEMBER='str' - Rename the member in the ZIP archive`
- `SWITCH: REMAIN - Remain existing files (no append) or member (with append) [FALSE]`
- `SWITCH: NOMKDIR - Don't create path if path not exists [FALSE]`
- `SWITCH: APPEND - Append member to this ZIP archive [FALSE] (use remain to prevent overwrite of members)`
- `SWITCH: FLUSH - Enforce flush in front of close file [FALSE]`
- `NUMBER: ACSTIM=num - Define the last access time for this file`
- `NUMBER: MODTIM=num - Define the last modification time for this file`
- `STRING: COMENT='str' - Define a comment for this ZIP archive`
- `NUMBER: FORMAT=AUTO/Z32/Z64 - Choose the format to write [AUTO]`
  - `AUTO - As needed (32 bit for small files and 64 for large ones)`
  - `Z32 - Always 32 bit format (old)`
  - `Z64 - Always 64 bit format (modern)`
- `NUMBER: ENCODE=UTF8/DOS/ASCII - Select encoding for file names and comments [UTF-8]`
  - `UTF8 - UTF-8 encoding (recommended)`
  - `DOS - IBM437 encoding (old 8 bit ASCII of ZIP files))`
  - `ASCII - IBM367 encoding (US ASCII (only 7 bit subset of UTF-8 and IBM437))`
- `SWITCH: NOXFLD - Don't write extra fields into the member header [FALSE]`
- `SWITCH: STREAM - Write streamed ZIP file, uses only sequential I/O, no seek [FALSE]`