ZLib, deflate, splitted output data
Posted: Wed Mar 21, 2012 3:10 pm
Hi, is there somebody who knows how to use zlib deflate to generate many independent files from one output data? Like split files for rar to part01, part02, etc. but independent.
I want to get data and deflate them to fixed size blocks with defined size BUT every deflated block must be zlib file. So I can extract part1 or part5 without need to have other parts.
For example:
1) Set output length to 100000 (set avail_out to this size)
2) Get full output buffer and save it to file
3) Call deflateEnd() and avoid errors because of not end of input data
4) Continue to 2
So I don't want to get whole compressed stream and split it to files, but force deflate to create many output files until there are data on input. Then you can simply extract all files and merge them to original one. There is no problem in avail_out size, deflate method automaticaly fills output buffer to max, but how to stop it now and continue with other data on infut without getting error in deflateEnd? Is there any way how to set avail_in to 0 and stop compression? What exactly deflateEnd() do?
Thnx for any help.
I want to get data and deflate them to fixed size blocks with defined size BUT every deflated block must be zlib file. So I can extract part1 or part5 without need to have other parts.
For example:
1) Set output length to 100000 (set avail_out to this size)
2) Get full output buffer and save it to file
3) Call deflateEnd() and avoid errors because of not end of input data
4) Continue to 2
So I don't want to get whole compressed stream and split it to files, but force deflate to create many output files until there are data on input. Then you can simply extract all files and merge them to original one. There is no problem in avail_out size, deflate method automaticaly fills output buffer to max, but how to stop it now and continue with other data on infut without getting error in deflateEnd? Is there any way how to set avail_in to 0 and stop compression? What exactly deflateEnd() do?
Thnx for any help.