zip.AddFile -- add file to zip archive
idx = zip.AddFile(id, f$[, table])
This function adds the file specified by f$ to the zip archive specified by id and returns the index of the newly added file. The optional table argument allows you to specify further options.

The following tags are currently recognized by the optional table argument:

This tag allows you to store this file with a new name in the zip archive. If you want to store the file in a subdirectory in the zip archive, you also have to use this tag and include the name of the subdirectory(s) in NewName. If NewName is omitted, the file will always be stored in the root directory of the zip archive.

This tag allows you to set the desired encryption method for the file. It can be set to one of the following special constants:

No encryption. This is the default.

Winzip AES-128 encryption.

Winzip AES-192 encryption.

Winzip AES-256 encryption.

If you specify the Encryption tag, it is also necessary to provide a password that is needed to decrypt the file. You can specify this password in the Password tag (see below). If you don't use the Password tag, the default password set using zip.SetDefaultPassword() is used.

If the Encryption tag has been set to a value different from #ZIP_EM_NONE (see above), this tag can be set to a password that should be used to protect the file. If you omit this tag, the default password set using zip.SetDefaultPassword() is used.

This tag can be used to set the desired compression method for the file. The following compression methods are currently supported:

This is the default setting. Currently the same as #ZIP_CM_DEFLATE.

Store the file uncompressed.

Compress the file using the bzip2 algorithm.

Deflate the file with the zlib algorithm and default options.

Note that only #ZIP_CM_DEFLATE and #ZIP_CM_STORE can be assumed to be universally supported.

When specifying this tag, you can also pass the CompressionFlags tag to set the compression level (see below).

This tag can be used to define the compression level. It ranges from 1 for the fastest compression and 9 for the highest. You can also pass 0 to use the compressor's default setting. Defaults to 0.

This tag can be used to add the file to the zip archive with a comment attached to it.

This tag can be used to change the file's datestamp. By default, the datestamp will be taken from the file specified in f$. If you'd like to assign a different datestamp to the file, then you need to pass a string in the standard Hollywood date format of dd-mmm-yyyy hh:mm:ss to this tag.

Note that this function doesn't immediately begin compressing the file and writing it to the zip archive. Instead, the file is just added into an internal list and compressing and writing will be done once you call zip.CloseArchive(). This means that you have to make sure that the file you specified in f$ is still available when you call zip.CloseArchive(), i.e. in case you pass the name of a temporary file to f$ you must not delete this temporary file before you call zip.CloseArchive().

identifier of the zip archive to use
path to a file to add to the zip archive
optional: table containing further options (see above)
index of newly added file in zip archive

Show TOC