I have a large amount of "input" data that I want to compress to multiple bzip2
streams, without writing data to multiple intermediate files.
Can I put a chunk of input data into a buffer, use BZ2_bzBuffToBuffCompress()
to compress that buffer to bzip2-flavored bytes, and repeat with subsequent BZ2_bzBuffToBuffCompress()
calls on fresh data, until I have no more input data left?
The bzip2 documentation says the following:
Compression in this manner is a one-shot event, done with a single call to this function. The resulting compressed data is a complete bzip2 format data stream. There is no mechanism for making additional calls to provide extra input data. If you want that kind of mechanism, use the low-level interface.
Does this mean I cannot re-run BZ2_bzBuffToBuffCompress()
on newly filled buffer-sized chunks of input data? Should I use BZ2_bzWrite()
instead?
EDIT
I actually meant outputting to one archive file, which could contain one or more bzip streams.