0

I have some data in an array,

uchar *data = "Data to be compressed."; [Some data]

I want to compress(gz) this data and get output in a buffer.

uchar gzData[MAX_LEN];

One way to do this is:

 1. Creating a `ogzstream` object.
 2. Writing this data into a temporary file
 3. close the temporary file.
 3. Create a `ifstream` object.
 4. Read the temporary file into buffer using ifstream object .

But I do not want to use a temporary file for this as it is slowing down the whole process.

Is there any direct method of compressing this data without using any intermediate file ??

techbull
  • 118
  • 2
  • 16
  • you do realize that what you are creating is a stream and not a file? There is filesystem interaction here. – niklasfi Feb 17 '14 at 10:08

1 Answers1

0

You can use a filtering streambuf to do this on the fly. It's pretty easy to do, but Boost::Iostreams has one already done for you.

James Kanze
  • 150,581
  • 18
  • 184
  • 329