Guess a size for the buffer, then after the decompression finishes, you can call ArraySink::TotalPutLength() to find out whether the buffer was large enough. Repeat the decompression with a larger buffer if it wasn't.

Another option is to use StringSink instead of ArraySink. But that way you run the risk of using up all of your memory (for example if the gzip file decompresses into 1GB of zeros), since you don't get a chance to limit the buffer size.

----- Original Message ----- From: "Sara Shoemaker" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, August 27, 2005 1:33 AM
Subject: Using FileSource and ArraySink with Gunzip


Hi -

I am quite confused.  I need to gunzip a file into
memory.  If I try to use the filters, I get into a
quandary about how big to allocate my memory buffer -
as follows:

char inputFileName = "myFile";
byte* buffer[ HOW_THE_HECK_DO_I_KNOW ];

FileSource(inputFileName, true,
            new Gunzip( new ArraySink( buffer,
sizeof(buffer) ));

Any advice would be appreciated.

Thanks
-Sara







Reply via email to