Zlib decoder which supports pkzip and gzip archives, and can be stored in a
pool.
In general it is not possible to stream pkzip archives. This is because the
format supports some quirky features which were important in the days of
floppy diskettes.
This class supports an important case where streaming is
possible: an archive which consists of a single file stored at
the start of the archive, using DEFLATE compression.
Needs linking with -lz.
Usage example:
importocean.io.compress.ZipStream;
autounzipper = newZipStreamDecompressor;
unzipper.reset();
try
{
unzipper.start();
}
catch (Exceptione)
{
// Error!
}
// `downloader` is a hypothetical source which provides chunks of// compressed data, eg downloaded from a socket// Before processing, it may be wise to check that the first bytes in// the file are equal to GZipFileSignature (for gzip files) or// ocean.util.compress.c.Zip.ZipLocalFileHeaderSignature (for pkzip); an// exception will be thrown if this is not true.foreach (compressed_chunk; downloader)
{
try
{
uncompressed = unzipper.decompress(compressed_chunk);
^
Stdout.format("{}", uncompressed);
}
catch (Exceptione)
{
// Error!
}
}
if (!unzipper.end())
{
// Error!
}
Zlib decoder which supports pkzip and gzip archives, and can be stored in a pool.
In general it is not possible to stream pkzip archives. This is because the format supports some quirky features which were important in the days of floppy diskettes.
This class supports an important case where streaming is possible: an archive which consists of a single file stored at the start of the archive, using DEFLATE compression.
Needs linking with -lz.
Usage example: