L’interface de VDS Renaissance est disponible en plusieurs langues. La documentation officielle est maintenue en anglais afin de garantir une référence unique, cohérente et toujours à jour.

ZIP

Windows Linux macOS

[VDS7]

Syntax

ZIP ADD, <handle>, FILE, <filename>

ZIP ADD, <handle>, DIR, <folder> {, R}

ZIP CLOSE, <handle>

ZIP EXTRACT, <archive> {, <folder>} {, <password>}

ZIP EXTRACTFILE, <archive>, <entry> {, <folder>} {, <password>}

Description

This command creates and extracts standard .zip archives (see ZIP archives). The ZIP engine is built into the core; no extra DLL is required.

To build an archive you first open it with @NEW(zip,<archive>[,<password>]), which returns a <handle>, then add entries, then close it:

ZIP ADD, <handle>, FILE, <filename> Adds a file to the open archive, stored under its base name.
ZIP ADD, <handle>, DIR, <folder> {, R} Adds the contents of a folder, stored under the folder's name. Add R to include sub-folders recursively.
ZIP CLOSE, <handle> Writes the archive to disk and releases the handle. Nothing is written before the close. If the archive was opened with a password, it is encrypted with WinZip AES-256.

To extract, no handle is needed — these work on any archive file:

ZIP EXTRACT, <archive> {, <folder>} {, <password>} Extracts all entries to <folder> (the current folder if omitted). Needed sub-folders are created.
ZIP EXTRACTFILE, <archive>, <entry> {, <folder>} {, <password>} Extracts a single named entry.

For an encrypted archive, give the password as the last parameter. Encryption is AES-256 in the interoperable WinZip AE-2 format (readable by 7-Zip, WinRAR and WinZip); it is authenticated, so a wrong password — or a tampered archive — fails with nothing written and @ZIP(error) set. See Encryption.

OK

OK is false if the archive or an entry cannot be read or written; @ZIP(error) then gives the message.

Example

REM build an encrypted backup
%z = @new(zip,backup.zip,SecretPhrase)
zip add,%z,FILE,report.txt
zip add,%z,DIR,images,R
zip close,%z

REM read it back
zip extract,backup.zip,C:\restore,SecretPhrase

See also