5 zip File Extraction
procedure
in : (or/c path-string? input-port)
entry-reader : (bytes? boolean? input-port? . -> . any) = (make-filesystem-entry-reader)
For each entry in the archive, the entry-reader procedure is called with three arguments: the byte string representing the entry name, a boolean flag indicating whether the entry represents a directory, and an input port containing the inflated contents of the entry. The default entry-reader unpacks entries to the filesystem; call make-filesystem-entry-reader to configure aspects of the unpacking, such as the destination directory.
procedure
(make-filesystem-entry-reader [ #:dest dest-path #:strip-count strip-count #:exists exists]) → (bytes? boolean? input-port? . -> . any) dest-path : (or/c path-string? #f) = #f strip-count : exact-nonnegative-integer? = 0
exists :
(or/c 'skip 'error 'replace 'truncate 'truncate/replace 'append 'update 'can-update 'must-truncate) = 'error
If dest-path is not #f, every path in the archive is prefixed to determine the destination path of the extracted entry.
If strip-count is positive, then strip-count path elements are removed from the entry path from the archive (before prefixing the path with dest-path); if the item’s path contains strip-count elements, then it is not extracted.
If exists is 'skip and the file for an entry already exists, then the entry is skipped. Otherwise, exists is passed on to open-output-file for writing the entry’s inflated content.
procedure
(read-zip-directory in) → zip-directory?
in : (or/c path-string? input-port?)
This procedure performs limited I/O: it reads the list of entries from the zip file, but it does not inflate any of their contents.
procedure
(zip-directory? v) → boolean?
v : any/c
procedure
(zip-directory-entries zipdir) → (listof bytes?)
zipdir : zip-directory?
procedure
(zip-directory-contains? zipdir name) → boolean?
zipdir : zip-directory? name : (or/c bytes? path-string?)
Directory entries match with or without trailing slashes.
procedure
(zip-directory-includes-directory? zipdir name) → boolean? zipdir : zip-directory? name : (or/c bytes? path-string?)
procedure
(unzip-entry path zipdir entry [entry-reader]) → void?
path : (or/c path-string? input-port?) zipdir : zip-directory? entry : (or/c bytes? path-string?)
entry-reader : (bytes? boolean? input-port? . -> . any) = (make-filesystem-entry-reader)
The entry parameter is a byte string whose name must be found in the zip file’s central directory. If entry is not a byte string, it is converted using path->zip-path.
The read-entry argument is used to read the contents of the zip entry in the same way as for unzip.
If entry is not in zipdir, an exn:fail:unzip:no-such-entry exception is raised.
procedure
(path->zip-path path) → bytes?
path : path-string?
struct
(struct exn:fail:unzip:no-such-entry exn:fail (entry) #:extra-constructor-name make-exn:fail:unzip:no-such-entry) entry : bytes?