How do I use std.zlib to write a struct of data to a binary file with compression?

TJB broughtj at gmail.com
Mon Sep 24 13:10:04 PDT 2012


Hello,

I am trying to save some data to compressed binary files.  I have 
my data in a struct, which I can write to a binary file just fine:

align(1) struct TradesBin {
   int ttim;
   int prc;
   int siz;
   short g127;
   short corr;
   char[2] cond;
   char ex;
}

auto fout = new BufferedFile(outfile, FileMode.Out);
fout.writeExact(&bin, TradesBin.sizeof);

Where bin is of type TradesBin, filled with data.  The question 
is how do I now do this with zlib to get compression?  
Suggestions and help are mightily appreciated!

TJB



More information about the Digitalmars-d-learn mailing list