This library provides access to ZIP files. ZIP files are used to store
SWI-Prolog resources. Ths library provides more high level access and
documentation in addition to the low level access provided as built in
as it is needed to bootstrap SWI-Prolog.
Access to a zip file is provided by means of a zipper object. This is
a blob that is subject to atom garbage collection. Collecting a zipper
closes the underlying OS access.
A zipper is a stateful object. We recognise the following states:
idle, scan, read_entry, write_entry and close. The interface
raise a permission_error when trying to make an illegal state
Being stateful, a zipper cannot be used simultaneously from multiple
threads. The zipper becomes owned by a thread when moving to scan
using zipper_goto/2. It is released after zipper_open_current/3 followed
by closing the stream.
- zip_open(+File, +Mode, -Zipper, +Options) is det
- Create a Zipper, providing access to File. Mode is one of
write. The Options list is currently ignored.
- zip_close(+Zipper) is det
- zip_close(+Zipper, +Options) is det
- Close a zipper. Options processed:
- If the zipper is open for writing, set the global comment
for the zip file.
- zipper_goto(+Zipper, +Where) is semidet
- Seek Zipper to a specified entry. Where is one of
- Go to the first entry. Fails if the zip is empty.
- Go to the next entry. Fails if there is no next entry.
- Go to the entry with the specified name.
- zipper_open_current(+Zipper, -Stream, +Options) is det
- Open the current entry as an input stream. Before this call the
caller must use zipper_goto/2 to position to archive. Options:
- Determine type and encoding of the stream. The semantics
is the same as for open/4.
true (default), release te archive for access by other
threads after the entry is closed.
It is allowed to call zip_close/1 immediately after this call, in
which case the archive is closed when the entry is closed.
- with_zipper(+Zipper, :Goal)
- Run Goal while holding ownership over Zipper.
- zipper_file_info(+Zipper, -Name, -Attrs) is det
- Obtain information about the current zip entry. Name is an atom
representing the name of the entry. Attrs is a dict holding:
- Size in the archive
- Bytes after decompression
- Numeric time stamp in Prolog native format (float
expressing seconds since Jan 1, 1970). Note that
the resolution of time in zip archives is one
- Optional additional fields.
- Direct pointer to this entry. May be used with zip_goto/2.
The following predicates are exported, but not or incorrectly documented.
- zipper_open_new_file_in_zip(Arg1, Arg2, Arg3, Arg4)
- zipper_members(Arg1, Arg2)
- zip_close(Arg1, Arg2)