I am trying to use the bzip2 bindings that are available on code.dlang.org/packages, but I am having a really hard time using it due to the pointers. It needs to be an array once it's decompressed.

Here is what I have:
import std.stdio;
import bzlib;

void main(string[] args)
{

   File f = File("./test.bz2");
   ubyte[] data = new ubyte[f.size];
  f.rawRead(data);
   writeln(data);

   ubyte* output;
   uint avail_out;
   bz_stream* stream = new bz_stream();
   stream.avail_out = avail_out;
   stream.next_out = output;

   int init_error = BZ2_bzDecompressInit(stream, 0, 0);
   int bzipresult = BZ2_bzDecompress(stream);

   stream.avail_in = cast(uint) data.length;
   stream.next_in = cast(ubyte*) data;

   bzipresult = BZ2_bzDecompress(stream);
   int read = stream.total_out_lo32;
   BZ2_bzDecompressEnd(stream);
   delete stream;
   writeln(output);
}

It's not working at all so any help would be very much appreciated.

Reply via email to