Boost logo

Boost Users :

Subject: [Boost-users] [bzip2 iostreams] [serialization] How to serialize an object into a bzip2 file and vice versa.
From: Sebastian Korf (teddy-sk_at_[hidden])
Date: 2009-09-11 09:39:08


Hi.

I right now managed to store objects via serialization onto harddisk.
Because these files are still big and i used the textstream to serialize
the object i decided to shrink the files...so far the plan :)
I rebuild the iostreams with bzip support (that was also quite a pain ;)
and now i can decompress a simple precompressed text file easily:

int main()
{
    using namespace std;
    using namespace boost::iostreams;
    ifstream file("E:\\test.txt.bz2", ios_base::in | ios_base::binary);
    filtering_streambuf<input> in;
    in.push(bzip2_decompressor());
    in.push(file);
    ofstream fileOutput("E:\\test2.text");
    copy(in,fileOutput);
}

But if i try to decompress a file which i serialized, bzip just runs
forever doing nothing.

SO my first question is, if someone knows why the serialized compressed
files can not be decompressed.

My second question is, if it is possible to serialize directly into a
compressed bz2 file.

I really looked around in the internet but still cannot get a clue so
please respond.
http://www.codeproject.com/KB/stl/zipstream.aspx?fid=16084&df=90&mpp=25&sort=Position&select=737834&tid=1192811
http://lists.boost.org/Archives/boost/2003/10/53755.php

Thanks,

SK


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net