Zip
libraryCreates and extracts `.zip` archives in the project workspace. Archiving a directory stores it under its own name (zipping `data` gives entries `data/...`), and extracting an archive never writes outside the destination directory. Symbolic links are stored as links and not followed. Password-protected archives are not supported.
- Kind Library, a global in every script
- Category Files & Documents
- Functions 2
Functions
create()
Section titled “create()”Zip.create(source: string, destination: string)→self Zips a file or a whole directory. A file is stored under its file name; a directory is stored together with its own name as the top folder, so zipping `data` and extracting the result gives `data/...` again. The archive is replaced if it exists, its missing parent directories are created, and the archive itself is left out when it lies inside the source directory. Throws `Failed to create zip archive` (for example `Source path does not exist`). No partial archive is left at the destination after a failure.
Parameters
-
sourcestring - File or directory to zip, relative to the workspace
-
destinationstring - Zip file to create, relative to the workspace
Returns
Example runs in CI
Fl.write("hello.txt", "hello")Zip.create("hello.txt", "hello.zip")Zip.extract("hello.zip", "unzipped")print(Fl.exists("unzipped/hello.txt"))extract()
Section titled “extract()”Zip.extract(archive: string, destination: string)→self Extracts a zip archive into a directory, creating the directory when needed. Existing files with the same name are overwritten. An entry whose path would end up outside the destination (for example `../x`), or a symbolic link pointing outside it, aborts the extraction. Throws `Failed to extract zip archive` when the archive is missing or not a zip file; entries extracted before an error stay on disk.
Parameters
-
archivestring - Zip file to extract, relative to the workspace
-
destinationstring - Directory to extract into, relative to the workspace
Returns