1/*  File:    swi/zip.pl
    2    Author:  Roy Ratcliffe
    3    Created: Jul 22 2021
    4    Purpose: SWI Zip Files
    5
    6Copyright (c) 2021, Roy Ratcliffe, Northumberland, United Kingdom
    7
    8Permission is hereby granted, free of charge,  to any person obtaining a
    9copy  of  this  software  and    associated   documentation  files  (the
   10"Software"), to deal in  the   Software  without  restriction, including
   11without limitation the rights to  use,   copy,  modify,  merge, publish,
   12distribute, sublicense, and/or sell  copies  of   the  Software,  and to
   13permit persons to whom the Software is   furnished  to do so, subject to
   14the following conditions:
   15
   16    The above copyright notice and this permission notice shall be
   17    included in all copies or substantial portions of the Software.
   18
   19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT  WARRANTY OF ANY KIND, EXPRESS
   20OR  IMPLIED,  INCLUDING  BUT  NOT   LIMITED    TO   THE   WARRANTIES  OF
   21MERCHANTABILITY, FITNESS FOR A PARTICULAR   PURPOSE AND NONINFRINGEMENT.
   22IN NO EVENT SHALL THE AUTHORS  OR   COPYRIGHT  HOLDERS BE LIABLE FOR ANY
   23CLAIM, DAMAGES OR OTHER LIABILITY,  WHETHER   IN  AN ACTION OF CONTRACT,
   24TORT OR OTHERWISE, ARISING FROM,  OUT  OF   OR  IN  CONNECTION  WITH THE
   25SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   26
   27*/
   28
   29:- module(swi_zip,
   30          [ zip_file_info/4,                     % +File,-Name,-Attrs,-Zipper
   31            zipper_codes/3                       % +Zipper,-Codes,+Options
   32          ]).   33:- autoload(library(readutil), [read_stream_to_codes/2]).   34:- autoload(library(zip), [zip_open/4, zip_close/1, zipper_file_info/3]).
 zip_file_info(+File, -Name, -Attrs, -Zipper) is nondet
Non-deterministically walks through the members of a zip File, moving the Zipper current member. It does not read the contents of the zip members, by design. You can use the Name argument to select a member or members before reading.
Arguments:
Zipper- unifies with the open Zipper for reading using zipper_codes/3 or zipper_open_current/3.
   46zip_file_info(File, Name, Attrs, Zipper) :-
   47    setup_call_cleanup(
   48        zip_open(File, read, Zipper, []),
   49        (   zipper_goto(Zipper, first),
   50            file_info(Zipper, Name, Attrs)
   51        ),
   52        zip_close(Zipper)
   53    ).
   54
   55file_info(Zipper, Name, Attrs) :- zipper_file_info(Zipper, Name, Attrs).
   56file_info(Zipper, Name, Attrs) :-
   57    zipper_goto(Zipper, next),
   58    file_info(Zipper, Name, Attrs).
 zipper_codes(+Zipper, -Codes, +Options) is semidet
Reads the current Zipper file as Codes. Options may be:
   67zipper_codes(Zipper, Codes, Options) :-
   68    setup_call_cleanup(
   69        zipper_open_current(Zipper, Stream, Options),
   70        read_stream_to_codes(Stream, Codes),
   71        close(Stream)
   72    )