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

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Sep 24 23:44:36 PDT 2012


On 25-Sep-12 00:10, TJB wrote:
> 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 {

Just a note: recently compiler changed so this align(1) have no effect 
on the fields alignment only on a struct as a whole.
So instead
align(1):
inside of struct should probably work.
>    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
>


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list