Danil Asotsky
Danil Asotsky

Reputation: 1241

zlib iostream wrapper with support stream append

I need iostream wrapper for zlib that allow to append data into end of existing stream.

gzopen() function in append mode follow the next rule. "When appending, gzopen does not test whether the file begins with a gzip stream, nor does it look for the end of the gzip streams to begin appending. gzopen will simply append a gzip stream to the existing file." E.g. opening of file with "a" option will create file with multiple compressed streams.

gzofstream wrapper for zlib translate std::ios_base::app in parameter list as "ab" mode of gzopen() function. As result, gzofstream will also create file with multiple streams.

However, in my application I need alternative behavior. Main module should open file in append mode (with std::ios_base::app option), write small data portion in the end of existing stream, and close the file. E.g., file should always contain single compressed stream after several open/close operation.

gzlog example from zlib has functionality close to required. However, it is pure C.

Can you propose some ready solutions for my task?

Upvotes: 2

Views: 992

Answers (1)

Danil Asotsky
Danil Asotsky

Reputation: 1241

It seems that ready solution is not exists for this case: iostream wrappers don't support append operation.

I have implemented own code based on gzlog and pure C (not C++).

Upvotes: 1

Related Questions