Read and write gzip files easily.
Adam D. Ruppe
destructionator at gmail.com
Wed Feb 19 08:36:28 PST 2014
On Wednesday, 19 February 2014 at 16:27:32 UTC, Artem Tarasov
wrote:
> Unfortunately, there's no standard module for processing
> gzip/bz2.
std.zlib handles gzip but it doesn't present a file nor range
interface over it.
This will work though:
void main() {
import std.zlib;
import std.stdio;
auto uc = new UnCompress();
foreach(chunk; File("testd.gz").byChunk(1024)) {
auto uncompressed = uc.uncompress(chunk);
writeln(cast(string) uncompressed);
}
// also look at anything left in the buffer
writeln(cast(string) uc.flush());
}
And if you are writing, use new Compress(HeaderFormat.gzip) then
call the compress method and write what it returns to teh file.
More information about the Digitalmars-d
mailing list