The (weinholt compression zip) library provides procedures for
reading and writing ZIP archives.
This library exports bindings that aren't easily identified as having to do with ZIP archives, so I suggest you use a prefix as described in Conflicting names.
The (weinholt compression zip extra) library is used to set and
retrieve file attributes, look for absolute/relative path attacks,
create directories, and handle system-specific file types. None of
this can really be done portably, so the default version of that
library does the minimum possible. A few implementation-dependent
overrides are included which allow directories to be created and
handle some attributes.
To learn about the file format, see http://www.info-zip.org/doc/. In brief: each file has a file record (followed by the file data), and the archive ends with a list of central directory records and a special end of central directory record. Some information is duplicated in the file and central directory records.
Returns the central directory of the ZIP archive in binary-input-port. This is a list of central directory records and the end of central directory record.
Uses the data in the central directory record cdir to read the associated file record from zip-input-port. The returned value is also referred to as a local file header.
Extracts the file associated with the local and central records. The zip-port is the same port the records were read from.
The extracted file will be created relative to the current working directory (or default filespec) and will retain as many attributes as possible from those recorded in the ZIP archive.
Extracts the file associated with the local and central records to the given binary output port dest-port. The zip-port is the same port the records were read from.
It is possible to preserve the file's attributes (at least if the extracted file is a regular byte stream) by using the accessors for local and central similarly to how the “extra” library uses that data.
Creating a ZIP archive is done by appending each file, and then when
done appending the central directory. The central directory is in this
case a list of central directory records returned by e.g.
append-file. The port the ZIP archive is written to must
support port-position and set-port-position!.
Note: Currently there is no compression performed when creating archives.
Appends the file given by filename to zip-port, which is a binary output port. Returns a central directory record.
Similar to
append-file, except no file is used. Instead the data for the file is read from the binary input port data-port. Because there is no file, all the file attributes need to be provided explicitly. A central directory record is returned.For a description of the attributes, see the accessors for file and central directory records.
Writes a list of central directory records to the zip-port and then appends the special end of central directory record. After this no more data should be written to the ZIP archive. The list of central directory records
centralsshould be those returned byappend-fileandappend-port.
Builds a complete ZIP archive that includes all the files specified by the list filenames and writes it to port, which should be a binary output port.
True if n represents a supported compression method. Currently only stored and deflated are supported. See
file-record-compression-method.
If an attempt was made to access an unsupported file record or to extract a file using an unsupported compression method then a condition will be raised that satisfies this predicate.
This is the minimum supported version of the ZIP standard required to extract the file. Currently vresion 2.0 is supported (which is encoded as the exact integer 20).
Various flags that can indiciate which compression option was used, etc. You can probably ignore these.
Returns an integer that represents the compression method that was used when storing the file associated with frec. Most ZIP files use only Deflate and store.
compression-storedmeans the file was stored without any compression.compression-shrunkis the obsolete Shrunk method.compression-reduced1is the obsolete Reduced method with factor 1.compression-reduced2same as above, factor 2.compression-reduced3same as above, factor 3.compression-reduced4same as above, factor 4.compression-implodedis the obsolete Implode method.compression-deflatedis the Deflate compression algorithm.compression-deflate64is a slightly modified Deflate.compression-pkimplodeis something else.compression-bzip2is BZIP2.
The number of bytes the file uses inside the ZIP archive.
The number of bytes the file will use when it has been decompressed.
The filename of the file. This might be different in the associated central directory record (e.g. due to mischief). This can also be the string
"-"if the file came from the standard input port.
An list of id and data pairs. This is used to encode file attributes, etc. See the file format specification for more information.
This is the version of the ZIP standard supported by the implementation that created the archive.
The ID number of the operating system on which the ZIP archive was created. See the file format specification for a full list (DOS is 0, Unix is 3).
This is the minimum supported version of the ZIP standard required to extract the file. Currently version 2.0 is supported (which is encoded as the exact integer 20).
The number of bytes the file uses inside the ZIP archive.
The number of bytes the file will use when it has been decompressed.
The number of the split archive that the file starts on. Note that there is no explicit support for split archives, so this is untested.
Bit 0 of this integer is set if the file is believed to be text. This might be useful for end of line conversion, but it is probably unreliable.
The file attributes of the file. The format depends on the os-made-by field.
See
file-record-extra. Note that some of the fields have the same ID here and in the file records, but slightly different encodings.
The number of the split archive where edir is located.
The number of the split archive where the central directory begins.
The number of records in the central directory in this split archive.
The number of records in the central directory for the whole archive.
A textual comment associated with the whole archive.
Version history:
(0 0) – Initial version