The ZipBlockReader class is used to parse a Zip archive. It exposes the
contents of the archive via an iteration interface. For instance, to loop
over all files in an archive, one can use either
foreach( entry ; reader )
...
Or
while( reader.more )
{
auto entry = reader.get;
...
}
See the ZipEntry class for more information on the contents of entries.
Note that this class can only be used with input sources which can be
freely seeked. Also note that you may open a ZipEntry instance produced by
this reader at any time until the ZipReader that created it is closed.
- this(const(char)[] path);
- Creates a ZipBlockReader using the specified file on the local
filesystem.
- this(InputStream source);
- Creates a ZipBlockReader using the provided InputStream. Please note
that this InputStream must be attached to a conduit implementing the
IConduit.Seek interface.
- void close();
- Closes the reader, and releases all resources. After this operation,
all ZipEntry instances created by this ZipReader are invalid and should
not be used.
- bool more();
- Returns true if and only if there are additional files in the archive
which have not been read via the get method. This returns true before
the first call to get (assuming the opened archive is non-empty), and
false after the last file has been accessed.
- ZipEntry get();
ZipEntry get(ZipEntry reuse);
- Retrieves the next file from the archive. Note that although this does
perform IO operations, it will not read the contents of the file.
The optional reuse argument can be used to instruct the reader to reuse
an existing ZipEntry instance. If passed a null reference, it will
create a new ZipEntry instance.
- int opApply(int delegate(ref ZipEntry) dg);
- This is used to iterate over the contents of an archive using a foreach
loop. Please note that the iteration will reuse the ZipEntry instance
passed to your loop. If you wish to keep the instance and re-use it
later, you must use the dup member to create a copy.