Gzip decompression without saving data to file.

C

Chaos

I have tried to search Google, but I cannot seem to find a library to
decompress a gzip string or char to a string or char. I want to write
something that allows libcurl to access a page, save the output to a
string. I do not want to save a page every time I access one.
 
J

James Kanze

I have tried to search Google, but I cannot seem to find a library to
decompress a gzip string or char to a string or char. I want to write
something that allows libcurl to access a page, save the output to a
string. I do not want to save a page every time I access one.

What does it mean, a "gzip string or char"? Gzip is a file
compression format; you could concevably use it on a string (but
it would have to be a very, very long string for it to make
sense), but certainly not on a single char. Note that gzip is
context sensitive. You cannot extract bytes from somewhere in
the middle of a gzip file, and decompress them, because the
compression algorithm depends on all of the data which came
before it.

If you want to read a gzipped file into your program, without
passing through an intermediate, decompressed file, the simplest
solution is to use a pipebuf---a streambuf which reads to and
writes from a pipe. You then open the pipebuf with something
like pipebuf( "gzip < filename.gz", std::ios::in ), and read as
from a normal file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,291
Messages
2,571,453
Members
48,132
Latest member
AnneHarpur

Latest Threads

Top