Common Lisp ZIP library
A library for .zip-file reading and writing, written in Common Lisp.
Written by David Lichteblau <email@example.com>.
Send bug reports to (list information).
Thanks to common-lisp.net for hosting.
2006-xx-yy: Fixed the gray stream port, including a data corruption bug that was in CVS for some time. (Thanks to Kevin Reid and others.) Switched to flexi-stream external-format functions for portability. Uses trivial-gray-streams now. Allegro 8.0 fix (thanks to Edi Weitz). Comment support (thanks to Surendra Singhi). Incompatible change: Don't bind
*locale* on Allegro anymore.
2005-04-05: ACL fixes (thank to Edi Weitz). Lispworks port (thanks to Sean Ross). Store
file-write-date (also fixes FilZip compatibility).
$ export CVSROOT=:pserver:firstname.lastname@example.org:/project/zip/cvsroot $ cvs login Logging in to :pserver:email@example.com:2401/project/zip/cvsroot CVS password: anonymous $ cvs co zip
Installation (without asdf-install):
$ ln -s `pwd`/zip.asd /your/system/directory * (asdf:operate 'asdf:load-op :zip)
Needs gray streams. Currently works out-of-the-box on SBCL, Lispworks, and ACL. Should be trivial to port to other Lisps.
Handles Unicode characters in filenames on ACL and Lispworks (within the zip-file), is waiting for someone to fix Unicode handling on SBCL.
Zip archives are represented as opaque handles. Entries of the zip-file are named by strings and represented as objects, too.
Function OPEN-ZIPFILE (pathname) => zipfile
pathname for reading and return a handle for it.
Function CLOSE-ZIPFILE (zipfile)
Close the file handle.
Macro WITH-ZIPFILE ((var pathname) &body body) => result of body
var to the result of
open-zipfile, evaluate body as an implicit progn and call
close-zipfile before exiting.
Function GET-ZIPFILE-ENTRY (name zipfile) => zipfile-entry
Return an entry handle for the file called
Function ZIPFILE-ENTRIES (zipfile) => hash-table
Return a hash-table mapping filenames to entry handles for all files contained in the zip archive.
Macro DO-ZIPFILE-ENTRIES ((name-var entry-var zipfile) &body body) => nil
Map over all entries in
entry-var to each file name and entry handle in turn. Establish implicit block named
nil around the loop.
Function ZIPFILE-ENTRY-NAME (zipfile-entry) => string
Return an entry's file name as a string.
Function ZIPFILE-ENTRY-CONTENTS (entry &optional stream) => see below
stream is given, extract
entry to the
(unsigned-byte 8) stream given as the argument. Otherwise, return the entry contents as an
(unsigned-byte 8) vector.
Function UNZIP (pathname target-directory &key if-exists verbose) => nil
Extract all entries from the zip archive at
if-exists as for cl:open.
zipwriters are handles used to create zip archives. They are distinct from the zip handles used for reading.
Macro WITH-OUTPUT-TO-ZIPFILE ((var pathname &key if-exists) &body body)
Function WRITE-ZIPENTRY (zipwriter name data &key file-write-date)
Append a new entry called
zipwriter. Read data from
(unsigned-byte 8) stream
data until EOF and compress it into "deflate"-format. Use
file-write-date as the entry's date and time. Default to
(file-write-date data), use 1980-01-01T00:00 if
Function ZIP (pathname source-directory &key if-exists)
Compress all files in
source-directory recursively into a new zip archive at
pathname. Note that entry file names will not contain the name