(lispkit archive zip)

Library (lispkit archive zip) provides an API for creating and managing zip archives. Zip archives are either persisted on the file system, or they are created in-memory. Zip archives can be opened either in read-only or read-write mode. They allow either files or in-memory data (in the form of bytevectors) to be included. Such zip entries are either a file, a directory, or a symbolic link. In an archive, files are stored in either compressed or uncompressed form.

Constructors

Procedure make-zip-archive creates an in-memory zip archive. If bytevector bvec is provided, the zip archive is created from the given binary data, otherwise, a new empty zip archive is returned. For a zip archive created from a bytevector, parameter mutable? determines if it is a read-only or read-write zip archive. In the latter case, mutable? has to be set to #t, the default is #f.

Creates a new empty read-write zip archive at the given file path.

Opens a zip archive at the given file path. By default, the zip archive is opened in read-only mode, unless mutable? is set to #t.

Properties of archives

Returns #t if obj refers to a zip archive, otherwise #f is being returned.

Returns #t if the given zip archive is mutable, i.e. opened in read-write mode, #f otherwise.

Procedure zip-archive-path returns the file path at which archive is being persisted. If archive is a in-memory zip archive, then #f is returned.

Procedure zip-archive-bytevector returns archive as a bytevector. This bytevector can be written to disk or used to create a in-memory copy of the zip archive.

Introspecting entries

Entries in zip archives are referred to via their relative file path in the archive. All procedures that provide information about a zip archive entry therefore expect two arguments: the zip archive and a file path.

Returns the number of entries in archive.

Returns a list of file paths for all entries of zip archive archive.

Returns #t if archive contains an entry with the given file path.

Returns #t if archive contains an entry for the given file path and this entry is stored in compressed form. If path does not refer to a valid entry in archive, the procedure zip-entry-compressed? fails with an error.

Returns #t if archive contains an entry for the given file path and this entry is a file. If path does not refer to a valid entry in archive, the procedure zip-entry-file? fails with an error.

Returns #t if archive contains an entry for the given file path and this entry is a directory. If path does not refer to a valid entry in archive, the procedure zip-entry-directory? fails with an error.

Returns #t if archive contains an entry for the given file path and this entry is a symbolic link. If path does not refer to a valid entry in archive, the procedure zip-entry-directory? fails with an error.

Returns the size of the compressed file for the entry at the given path in bytes. If path does not refer to a valid entry in archive, the procedure zip-entry-compressed-size fails with an error.

Returns the size of the uncompressed file for the entry at the given path in bytes. If path does not refer to a valid entry in archive, the procedure zip-entry-uncompressed-size fails with an error.

Adding and removing entries

Adds the file, directory, or symbolic link at path relative to path base to the given zip archive. The corresponding entry in archive is identified via path. The file is stored in uncompressed form if compressed? is set to #f. The default for compressed? is #t.

Adds a new file entry to archive at path based on the content of bytevector bvec. The entry is stored in uncompressed form if compressed? is set to #f. The default for compressed? is #t. time is a date-time object as defined by library (lispkit date-time) which defines the modification time of the new entry.

Deletes the entry at path from archive. Procedure delete-zip-entry fails if the entry does not exist or if the archive is opened in read-only mode.

Extracting entries

Extracts the entry at path in archive and stores it on the file system at path relative to path base.

Returns the file entry at path in archive in form of a bytevector. Procedure read-zip-entry fails if the entry does not exist or if the entry is not a file entry.

Last updated