Boost logo

Boost Users :

Subject: [Boost-users] boost::iostream exception
From: Lloyd (lloyd_at_[hidden])
Date: 2008-10-06 10:56:37


Hi,

I am trying to decompress a file using boost::iostreams (1.35.0) library
built with zlib-1.2.3 . I am able to decompress the file with other
utilities but this program throws me an exception saying "gzip error". I
am able to uncompress other gzipped files. What could be the reason for
the exception? Any help is very much appreciated.

Thanks
 Lloyd

The decompress function is also added here
==========================================

bool ParseHttp::Decompress(const char* inBuff, int inLen,char** outBuff,
int* OutLen,int type)
{
        enum
        {
                CHUNK=4096
        };
        if(inBuff==NULL)
                return false;
        filtering_streambuf<input> in;
        switch(type)
        {
                case GZIP:
                        in.push(gzip_decompressor());
                break;
                case ZLIB:
                        in.push(zlib_decompressor());
                        break;
        }
        
        in.push(boost::make_iterator_range((const char*)inBuff,(const
char*)inBuff+inLen));
        vector<vUnzip*> unZipV;
        int totLen=0;
        while(1)
        {
                char* data=new char[CHUNK];
                int xyz=0;
                try
                {
                 xyz=boost::iostreams::read(in,data,CHUNK);
                }
                catch(exception& e)
                {
                        if(debug)
                                cout<<e.what()<<endl;
                }
                unZipV.push_back(new vUnzip(data,xyz));
                totLen+=xyz;
                if(xyz!=CHUNK)
                        break;
        }

    *outBuff=new char[totLen];
        int g=0;
        for(int k=0;k<unZipV.size();++k)
        {
                memcpy((*outBuff)+g,unZipV[k]->ptr,unZipV[k]->len);
                g+=unZipV[k]->len;
                delete unZipV[k];
        }
        *OutLen=totLen;
        return true;
}

______________________________________
Scanned and protected by Email scanner


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