Boost logo

Boost Users :

From: Hin-Tak Leung (hintak_leung_at_[hidden])
Date: 2006-06-12 16:33:19


What I would like to do is to skip over part of a gzip'ed
input, in a manner similiar to calling gzseek() in C, but I don't seem
to be able to do that. Since it is possible to do it in C (somewhat slowly
and there is no bzseek), I was thinking of something similiar to:

namespace boost_io = boost::iostreams;

boost_io::filtering_istream *instr = new boost_io::filtering_istream();
            /* one of these two */
            //instr->push(boost_io::gzip_decompressor());
            instr->push(boost_io::bzip2_decompressor());
        instr->push(boost_io::file_source(m_FileName.c_str(),
                std::ios::in | std::ios::binary));
        // skip the header
        //instr->seekg(boost_io::offset_to_position(m_iHeaderBytes),
     std::ios_base::beg);
        instr->seekg(boost_io::offset_to_position(m_iHeaderBytes));
         int32_t datasize = BUFFER_ZIZE;
        m_lpData = new char[datasize];
        std::cout << "position before:\t " << instr->tellg() << std::endl;
        instr->read(m_lpData, datasize);
        std::cout << "position after:\t " << instr->tellg() << std::endl;

But I tellg() returns 0 and datasize without the push::decompressor,
and -1/-1 when the decompressor is pushed.

Am I doing something wrong? I know streams aren't really seekable,
but I was hoping that there is a poorman's seek (like gzseek - which is
essentially read and throw-away) that's implementable.

The incentive - is to have transparent decompression of input
in some legacy code - I don't really want to modify every read to gzread,
or bzread, for example...

Thanks a lot.

Hin-Tak Leung

Send instant messages to your online friends http://uk.messenger.yahoo.com


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