zippy
1.0.0A fast zip archive library
About Zippy
Zippy is a library for the PKWARE Zip archive format. It can read and write zip files.
Feature list
Archive inspection without extraction
Zip64 support
Split archive support
PKWARE decryption
Fast deflate decompression thanks to 3bz
Operates on streams and vectors
Can compress stream->stream
Extensible for other encryption and compression mechanisms
How To
For this tutorial we will assume the org.shirakumo.zippy
package has a local-nickname of zippy
.
Extracting a zip file to disk is straight-forward:
(zippy:extract-zip "file.zip" "~/")
Similarly, compressing a file or directory to a zip:
(zippy:compress-zip "foo" "file.zip")
You can also compress things from in memory:
(zippy:compress-zip #(8 0 8) "file.zip")
In order to simply examine a zip file's contents:
(zippy:with-zip-file (zip "file.zip")
(zippy:entries zip))
The source zip does not have to be a path to a file on disk, but may also be an octet vector or a file-stream.
You can look at the raw payload of a zip-entry
by using decode-entry
. All of the other metadata is stored directly in the entry and does not require decoding.
For greater control when constructing a zip file, you can manually create zip-entry
instances yourself and pass the final zip-file
instance to compress-zip
.
Split Zip Files
When reading a split zip file from disk, Zippy will take care of accessing the other zip parts automatically. However, when decoding from an octet vector, Zippy has no way of guessing where to get the rest of the data from and will signal an error of type archive-file-required
with the requested disk
id. You should then invoke the use-value
restart with a suitable io
instance to continue the decoding.
Unsupported Features
The following features remain unsupported at the moment:
Encrypted or compressed central directory
PKWARE-style strong encryption
Compression methods other than deflate
Handling of additional metadata in third-party extra structures
With the exception of the central directory encryption however, the architecture is designed in such a way that additional encryption and compression algorithms can be added in a pluggable and easy way at a later point. See make-decompression-state
, make-compression-state
, make-decryption-state
, make-encryption-state
.
System Information
Definition Index
-
ORG.SHIRAKUMO.ZIPPY
No documentation provided.-
EXTERNAL SPECIAL-VARIABLE *COMPATIBILITY*
The default file attribute compatibility flag.
-
EXTERNAL SPECIAL-VARIABLE *VERSION*
The max zip file version supported by this library.
-
EXTERNAL CLASS ZIP-ENTRY
Representation of a file entry in a zip archive. Unless you are constructing an archive, this does /not/ contain the actual entry data payload. See ZIP-FILE See CRC-32 See DISK See OFFSET See SIZE See UNCOMPRESSED-SIZE See EXTRA-FIELDS See VERSION See ATTRIBUTES See ENCRYPTION-METHOD See COMPRESSION-METHOD See LAST-MODIFIED See FILE-NAME See COMMENT See CONTENT
-
EXTERNAL CLASS ZIP-FILE
Representation of a full zip archive. In order to ensure that all potentially open streams that the zip-file may hold are closed, call CL:CLOSE. See ENTRIES See DISKS See COMMENT See DECODE-FILE See CL:CLOSE
-
EXTERNAL CONDITION ARCHIVE-FILE-REQUIRED
Condition signalled if data from another disk (split file) is required. When this condition is signalled, a USE-VALUE restart must be available. If invoked, the value must be an IO value that supplies the data of the requested DISK. See DISK See DECODE-FILE See DECODE-ENTRY
-
EXTERNAL STRUCTURE AES-EXTRA-DATA
No documentation provided. -
EXTERNAL STRUCTURE DATA-STREAM-ALIGNMENT
No documentation provided. -
EXTERNAL STRUCTURE ENCRYPTION-HEADER
No documentation provided. -
EXTERNAL STRUCTURE INFOZIP-UNICODE-COMMENT
No documentation provided. -
EXTERNAL STRUCTURE INFOZIP-UNICODE-PATH
No documentation provided. -
EXTERNAL STRUCTURE KEY-PROVIDER-RECORD
No documentation provided. -
EXTERNAL STRUCTURE MICROSOFT-OPEN-PACKAGING-GROWTH-HINT
No documentation provided. -
EXTERNAL STRUCTURE MVS
No documentation provided. -
EXTERNAL STRUCTURE NTFS
No documentation provided. -
EXTERNAL STRUCTURE OPENVMS
No documentation provided. -
EXTERNAL STRUCTURE OS/2
No documentation provided. -
EXTERNAL STRUCTURE PATCH-DESCRIPTOR
No documentation provided. -
EXTERNAL STRUCTURE PKCS7-ENCRYPTION-RECIPIENT-CERTIFICATE-LIST
No documentation provided. -
EXTERNAL STRUCTURE PKCS7-STORE
No documentation provided. -
EXTERNAL STRUCTURE POLICY-DECRYPTION-KEY-RECORD
No documentation provided. -
EXTERNAL STRUCTURE POLICY-KEY-DATA-RECORD
No documentation provided. -
EXTERNAL STRUCTURE RECORD-MANAGEMENT-CONTROLS
No documentation provided. -
EXTERNAL STRUCTURE UNIX
No documentation provided. -
EXTERNAL STRUCTURE VECTOR-INPUT
Representation of vector input/output state. See VECTOR-INPUT-VECTOR See VECTOR-INPUT-INDEX See VECTOR-INPUT-START See VECTOR-INPUT-END
-
EXTERNAL STRUCTURE X509-CENTRAL-DIRECTORY
No documentation provided. -
EXTERNAL STRUCTURE X509-FILE
No documentation provided. -
EXTERNAL STRUCTURE ZIP64-EXTENDED-INFORMATION
No documentation provided. -
EXTERNAL STRUCTURE ZIPIT-MACINTOSH-LONG
No documentation provided. -
EXTERNAL STRUCTURE ZIPIT-MACINTOSH-SHORT-DIR
No documentation provided. -
EXTERNAL STRUCTURE ZIPIT-MACINTOSH-SHORT-FILE
No documentation provided. -
EXTERNAL TYPE-DEFINITION IO
Type for objects that Zippy can decode from or encode to. Decoding can only happen from an input with a fixed end and the ability to seek -- in effect file-streams and vectors. Encoding can happen to any stream and vector. See CL:STREAM See CL:FILE-STREAM See VECTOR-INPUT See SEEK See HAS-MORE See INDEX See START See END See SIZE See UB32 See OUTPUT See PARSE-STRUCTURE* See WRITE-STRUCTURE* See PARSE-STRUCTURE See WITH-IO
-
EXTERNAL FUNCTION COMPRESS-ZIP
- FILE
- TARGET
- &KEY
- START
- END
- IF-EXISTS
- PASSWORD
Compresses the contents of the zip file to the given output. FILE should be a ZIP-FILE. TARGET should be a suitable target for WITH-IO. See WITH-IO See ENCODE-FILE See ZIP-FILE
-
EXTERNAL FUNCTION COMPRESSION-METHOD-ID
- NAME
Returns the compression method ID for the given name. If The name is not known, an error is signalled.
-
EXTERNAL FUNCTION COMPRESSION-METHOD-NAME
- ID
Returns the compression method name for the given ID. The name should be one of NIL :shrink :reduce-1 :reduce-2 :reduce-3 :reduce-4 :implode :tokenizing :deflate :deflate64 :pkware-implode :reserved :bzip2 :reserved :lzma :reserved :cmpsc :reserved :terse :lz77 :zstd :jpeg :wavpack :ppmd :ae-x If the ID is not known, an error is signalled.
-
EXTERNAL FUNCTION DECODE-ENTRY
- FUNCTION
- ENTRY
- &KEY
- PASSWORD
Decode the data payload of the ZIP-ENTRY FUNCTION will be called repeatedly with three arguments: An octet buffer with the raw data A start index to the beginning of valid data An end index to the end of valid data PASSWORD should be supplied if the entry is encrypted. If the entry is encrypted, but no password is supplied, or the password is detectably incorrect, an error is signalled. The password may be a string or an octet-vector. If an error is detected during decoding of the payload, an error is signalled. If the zip file is split a condition of type ARCHIVE-FILE-REQUIRED may be signalled. See ENTRY-TO-FILE See ENTRY-TO-STREAM See ENTRY-TO-VECTOR See ARCHIVE-FILE-REQUIRED
-
EXTERNAL FUNCTION DECODE-FILE
- INPUT
Decode the given IO into a ZIP-FILE. If the zip file is split, will signal a condition of type ARCHIVE-FILE-REQUIRED for every disk that is required to read the central directory of the zip file. May signal warnings if data mismatch or other correctable corruption is detected in the zip file. May signal an error if an incorrectable corruption is detected in the zip file, or if the file is missing vital support structures that would make it a valid zip file. See WITH-ZIP-FILE See ARCHIVE-FILE-REQUIRED
-
EXTERNAL FUNCTION DECODE-STRUCTURE
- VECTOR
- INDEX
Decodes a structure from the given vector at the given starting position. A signature is expected at the input position. If no signature is available, or if it is not recognised, an error is signalled. Returns the structure instance and the ending index.
-
EXTERNAL FUNCTION ENCODE-FILE
- ZIP-FILE
- OUTPUT
- &KEY
- PASSWORD
Encodes the given zip-file to the output IO. This currently does not support split archive creation. All the entries will be written to the output. This will cause the ZIP-ENTRIES in the ZIP-FILE to be modified. In particular, SIZE, CRC-32, and UNCOMPRESSED-SIZE will be set, and LAST-MODIFIED, FILE-NAME, ATTRIBUTES, and COMPRESSION-METHOD may be set. The created Zip file will include Zip64 metadata regardless of whether this is required, but it will only enforce Zip64 decoding if the number of entries, or the size of an entry exceeds the possible bounds of traditional 32-bit zip files. If an encryption-method is specified for any entry, PASSWORD must be passed and will be used to encrypt the file. See ZIP-FILE See ZIP-ENTRY
-
EXTERNAL FUNCTION ENCODE-STRUCTURE
- STRUCTURE
- VECTOR
- INDEX
Encodes the given structure to the vector at the given starting position. This will encode it including its signature, if any. Returns the ending index.
-
EXTERNAL FUNCTION ENCRYPTION-METHOD-ID
- NAME
Returns the encryption method ID for the given name. If The name is not known, an error is signalled.
-
EXTERNAL FUNCTION ENCRYPTION-METHOD-NAME
- ID
Returns the encryption method name for the given ID. The name should be one of :des :rc2 :3des-168 :3des-112 :aes-128 :aes-192 :aes-256 :rc2 :blowfish :twofish :rc4 :unknown If the ID is not known, an error is signalled.
-
EXTERNAL FUNCTION END
- IO
Returns the ending index of the IO. See IO
-
EXTERNAL FUNCTION ENTRY-TO-FILE
- PATH
- ENTRY
- &KEY
- IF-EXISTS
- PASSWORD
- RESTORE-ATTRIBUTES
Decodes the contents of the entry to the given path. This will attempt to restore the same file attributes as are contained in the entry's metadata, unless :RESTORE-ATTRIBUTES NIL is passed. See DECODE-ENTRY See CL:OPEN See ZIP-ENTRY
-
EXTERNAL FUNCTION ENTRY-TO-STREAM
- STREAM
- ENTRY
- &KEY
- PASSWORD
Decodes the contents of the entry to the given octet input-stream. See DECODE-ENTRY See ZIP-ENTRY
-
EXTERNAL FUNCTION ENTRY-TO-VECTOR
- ENTRY
- &KEY
- VECTOR
- START
- PASSWORD
Decodes the contents of the entry to an octet vector. If an octet vector is passed explicitly through :VECTOR, the vector must be at least START+(UNCOMPRESSED-SIZE ENTRY) big. See DECODE-ENTRY See ZIP-ENTRY
-
EXTERNAL FUNCTION EXTRACT-ZIP
- FILE
- PATH
- &KEY
- IF-EXISTS
- PASSWORD
Extracts the contents of the zip file to the given directory. FILE may either be a ZIP-FILE, or a suitable input for WITH-ZIP-FILE. PATH should be a directory pathname designator. See ZIP-FILE See ENTRY-TO-FILE See WITH-ZIP-FILE
-
EXTERNAL FUNCTION FILE-ATTRIBUTE-ID
- NAME
Returns the file attribute ID for the given name. If The name is not known, an error is signalled.
-
EXTERNAL FUNCTION FILE-ATTRIBUTE-NAME
- ID
Returns the file attribute name for the given ID. The name should be one of :ms-dos :amiga :open-vms :unix :vm/cms :atari-st :os/2 :macintosh :z-system :cp/m :ntfs :mvs :vse :acorn-risc :vfat :alternate-mvs :beos :tandem :os/400 :darwin If the ID is not known, an error is signalled.
-
EXTERNAL FUNCTION HAS-MORE
- IO
Returns whether the io has input left to read, or space left to write to. See IO
-
EXTERNAL FUNCTION INDEX
- IO
Returns the current index into the IO. This should always be in the range of [START, END]. See IO
-
EXTERNAL FUNCTION OUTPUT
- IO
- ARRAY
- START
- END
Writes the given array of octets to the IO. If the IO does not have sufficient space available, an error is signalled. See IO
-
EXTERNAL FUNCTION PARSE-STRUCTURE*
- IO
Parses a structure from the IO assuming a leading 32 bit signature. If no suitable structure can be found, an error is signalled. Otherwise, the parsed structure instance is returned. This advances the IO index. See IO
-
EXTERNAL FUNCTION READ-STRUCTURE
- STREAM
Decodes a structure from the given stream. A signature is expected at the input position. If no signature is available, or if it is not recognised, an error is signalled. Returns the structure instance otherwise.
-
EXTERNAL FUNCTION SEEK
- IO
- TARGET
Seek the io to the requested index. If the index is outside the allowed ranges, an error is signalled. See IO
-
EXTERNAL FUNCTION START
- IO
Returns the starting index of the IO. See IO
-
EXTERNAL FUNCTION UB32
- IO
Reads a 32 bit unsigned integer from the IO and returns it. This will advance the IO index. See IO
-
EXTERNAL FUNCTION VECTOR-INPUT-END
- INSTANCE
Returns the ending index of the vector. See VECTOR-INPUT
-
EXTERNAL FUNCTION VECTOR-INPUT-INDEX
- INSTANCE
Accesses the current index into the vector. See VECTOR-INPUT
-
EXTERNAL FUNCTION (SETF VECTOR-INPUT-INDEX)
- VALUE
- INSTANCE
No documentation provided. -
EXTERNAL FUNCTION VECTOR-INPUT-START
- INSTANCE
Returns the starting index of the vector. See VECTOR-INPUT
-
EXTERNAL FUNCTION VECTOR-INPUT-VECTOR
- INSTANCE
Returns the vector the vector-input is backing. See VECTOR-INPUT
-
EXTERNAL FUNCTION WRITE-STRUCTURE
- STRUCTURE
- STREAM
Encodes the given structure to the stream. This will encode it including its signature, if any.
-
EXTERNAL FUNCTION WRITE-STRUCTURE*
- STRUCTURE
- IO
Writes the given structure to the IO. This advances the IO index. See IO
-
EXTERNAL GENERIC-FUNCTION ATTRIBUTES
- OBJECT
Accesses the file attributes. This should be a list of two entries, the file attribute compatibility identifier, and the actual attributes encoded as an integer. For ZIP-ENTRIES that are backed by a file, this entry is computed automatically when the entry is encoded. See FILE-ATTRIBUTE-NAME See ZIP-ENTRY See ORG.SHIRAKUMO.FILE-ATTRIBUTES:PERMISSIONS
-
EXTERNAL GENERIC-FUNCTION (SETF ATTRIBUTES)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CALL-WITH-COMPRESSED-BUFFER
- FUNCTION
- VECTOR
- START
- END
- STATE
Call the supplied function with a compressed buffer. The function is called with three arguments: An octet buffer with the compressed data A start index to the beginning of valid data An end index to the end of valid data The supplied STATE must be a state obtained through MAKE-COMPRESSION-STATE. The VECTOR, START, and END supply the octets to compress. You may call this function repeatedly with new input to compress until the full region has been processed. The supplied function likewise may be called multiple times per compression run. See MAKE-COMPRESSION-STATE
-
EXTERNAL GENERIC-FUNCTION CALL-WITH-DECOMPRESSED-BUFFER
- FUNCTION
- VECTOR
- START
- END
- STATE
Call the supplied function with a decompressed buffer. The function is called with three arguments: An octet buffer with the decompressed data A start index to the beginning of valid data An end index to the end of valid data The supplied STATE must be a state obtained through MAKE-DECOMPRESSION-STATE. The VECTOR, START, and END supply the octets to decompress. You may call this function repeatedly with new input to decompress until the full region has been processed. The supplied function likewise may be called multiple times per decompression run. See MAKE-DECOMPRESSION-STATE
-
EXTERNAL GENERIC-FUNCTION CALL-WITH-DECRYPTED-BUFFER
- FUNCTION
- INPUT
- LENGTH
- STATE
Call the supplied function with a decrypted buffer. The function is called with three arguments: An octet buffer with the decrypted data A start index to the beginning of valid data An end index to the end of valid data The supplied STATE must be a state obtained through MAKE-DECRPTIION-STATE. The VECTOR, START, and END supply the octets to decrypt. You may call this function repeatedly with new input to decrypt until the full region has been processed. The supplied function likewise may be called multiple times per decryption run. See MAKE-DECRYPTION-STATE
-
EXTERNAL GENERIC-FUNCTION CALL-WITH-ENCRYPTED-BUFFER
- FUNCTION
- VECTOR
- START
- END
- STATE
Call the supplied function with an encrypted buffer. The function is called with three arguments: An octet buffer with the encrypted data A start index to the beginning of valid data An end index to the end of valid data The supplied STATE must be a state obtained through MAKE-ENCRYPTION-STATE. The VECTOR, START, and END supply the octets to encrypt. You may call this function repeatedly with new input to encrypt until the full region has been processed. The supplied function likewise may be called multiple times per encryption run. See MAKE-ENCRYPTION-STATE
-
EXTERNAL GENERIC-FUNCTION COMMENT
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF COMMENT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION COMPRESSION-METHOD
- OBJECT
Accesses the compression method used to compress the file contents. This should either be NIL or a keyword naming the compression method. See COMPRESSION-METHOD-NAME See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF COMPRESSION-METHOD)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CONTENT
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF CONTENT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CRC-32
- OBJECT
Accesses the CRC-32 checksum of the file contents. This is computed and set automatically when the entry is encoded. See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF CRC-32)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION DISK
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF DISK)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION DISKS
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF DISKS)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ENCRYPTION-METHOD
- OBJECT
Accesses the encryption method used to encrypt the file contents. This should either be NIL, a keyword, or a list of a keyword and extra parameters. The keyword identifies the name of the encryption method. Additionally to the names listed in ENCRYPTION-METHOD-NAME, the names :AE-1 and :AE-2 are allowed. See ENCRYPTION-METHOD-NAME See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF ENCRYPTION-METHOD)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ENTRIES
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF ENTRIES)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION EXTRA-FIELDS
- OBJECT
Accesses the list of extra data structures for the entry. This slot should not be set by the user. See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF EXTRA-FIELDS)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FILE-NAME
- OBJECT
Accesses the relative path designating where the file belongs on a hirearchical file system. When the entry is encoded and this slot is unset, it may be computed automatically if the entry is backed by a file. Otherwise, an error is signalled. The path must be relative, and must use forward slashes as the directory separator. See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF FILE-NAME)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LAST-MODIFIED
- OBJECT
Accesses the universal time designating the last time the entry's contents were modified. If unset, and the entry is backed by a file, this slot is automatically computed when the entry is encoded. See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF LAST-MODIFIED)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION MAKE-COMPRESSION-STATE
- FORMAT
- &KEY
- BUFFER
Create the state necessary to compress given the requested compression format. If required, the supplied buffer spec should be used to create the output buffer for the compression. The buffer spec may be either NIL for a default buffer, an octet vector, or an integer for an octet vector of the given size. See CALL-WITH-COMPRESSED-BUFFER
-
EXTERNAL GENERIC-FUNCTION MAKE-DECOMPRESSION-STATE
- FORMAT
- &KEY
- BUFFER
Create the state necessary to decompress given the requested compression format. If required, the supplied buffer spec should be used to create the output buffer for the decompression. The buffer spec may be either NIL for a default buffer, an octet vector, or an integer for an octet vector of the given size. See CALL-WITH-DECOMPRESSED-BUFFER
-
EXTERNAL GENERIC-FUNCTION MAKE-DECRYPTION-STATE
- FORMAT
- INPUT
- PASSWORD
- &KEY
- BUFFER
- &ALLOW-OTHER-KEYS
Create the state necessary to decrypt given the requested encryption format. If required, the supplied buffer spec should be used to create the output buffer for the decryption. The buffer spec may be either NIL for a default buffer, an octet vector, or an integer for an octet vector of the given size. The given password may be a string or octet vector supplying the password for decryption. See CALL-WITH-DECRYPTED-BUFFER
-
EXTERNAL GENERIC-FUNCTION MAKE-ENCRYPTION-STATE
- FORMAT
- PASSWORD
- &KEY
- BUFFER
Create the state necessary to encrypt given the requested encryption format. If required, the supplied buffer spec should be used to create the output buffer for the encryption. The buffer spec may be either NIL for a default buffer, an octet vector, or an integer for an octet vector of the given size. See CALL-WITH-ENCRYPTED-BUFFER
-
EXTERNAL GENERIC-FUNCTION OFFSET
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF OFFSET)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION SIZE
- IO
-
EXTERNAL GENERIC-FUNCTION (SETF SIZE)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION UNCOMPRESSED-SIZE
- OBJECT
Accesses the octet size of the entry's uncompressed data payload. If unset, this slot is automatically computed when the entry is encoded. See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF UNCOMPRESSED-SIZE)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION VERSION
- OBJECT
Returns the Zip file version needed to extract this entry. The version is a list of two integers. This slot should not be set by the user. See ZIP-ENTRY
-
EXTERNAL GENERIC-FUNCTION (SETF VERSION)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ZIP-FILE
- OBJECT
-
EXTERNAL GENERIC-FUNCTION (SETF ZIP-FILE)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL MACRO DEFINE-BYTE-STRUCTURE
- NAME
- &BODY
- RECORDS
Define a new byte-coded structure. NAME can either be the name of the structure, or a list of the name and the signature that identifies the record uniquely. If a signature is given, the structure is registered and can be used with the standard functions DECODE/READ/ENCODE/WRITE-STRUCTURE. Each RECORD must be a list matching (NAME TYPE &optional COUNT) Where NAME identifies the field, TYPE identifies the name field's bit type, and COUNT the number of expected entries for a variable sized record. If COUNT is specified, it may be an arbitrary expression that can reference earlier record values by name, and the resulting slot value will be an octet vector of that length. The special record name SIZE may be used to identify a field that identifies the maximal size of the remaining structure payload. Any structure fields that would come after the dynamically read size has run out will be initialised to NIL. TYPE may be one of ub8 ub16 ub32 ub64 This will generate a structure of NAME with the given records as slots, as well as four functions to encode and decode the structure, and one function to construct it. These functions are constructed according to the following schema: (MAKE/DECODE/READ/ENCODE/WRITE)-NAME The given function names are interned in the current package. See DECODE-STRUCTURE See READ-STRUCTURE See ENCODE-STRUCTURE See WRITE-STRUCTURE
-
EXTERNAL MACRO PARSE-STRUCTURE
- STRUCTURE-TYPE
- IO-VAR
Parse the given structure type from the IO. This advances the IO index. See IO
-
EXTERNAL MACRO WITH-IO
- IO
- TARGET
- &REST
- ARGS
- &BODY
- BODY
Wraps TARGET in an appropriate IO context. TARGET may be a string or pathname, a stream, or a vector. In the case of a pathname or string, IF-EXISTS and DIRECTION can be passed as arguments for OPEN. In the case off a vector, START and END may be passed to designate a sub-range of the vector. See IO
-
EXTERNAL MACRO WITH-ZIP-FILE
- FILE
- INPUT
- &KEY
- START
- END
- &BODY
- BODY
Open a zip file. INPUT may be a pathname or string to designate a local file, a seekable stream to read from, or an octet-vector to decode. If decoding is successful, FILE will be bound to the resulting ZIP-FILE instance. This instance is only valid within BODY. After leaving the BODY, you may still access metadata and zip entries, but you may not use DECODE-ENTRY to extract an entry's payload. If the zip file is split and the supplied INPUT is a pathname designator, other split disks will be determined automatically by using the same pathname, but substituting the pathname-type by the scheme z{DISK} . If INPUT is not a pathname designator, a condition of type ARCHIVE-FILE-REQUIRED is signalled for every split disk that is required. See ZIP-FILE See DECODE-FILE See DECODE-ENTRY See ARCHIVE-FILE-REQUIRED
-