Boost logo

Boost Users :

Subject: [Boost-users] [iostreams] gzip problem
From: Olaf Krzikalla (olaf.krzikalla_at_[hidden])
Date: 2014-02-21 08:00:52


Hi @boost,

I have a file format containing chunks of gzipped data (using
gzip_decompressor/gzip_compressor). Inbetween these chunks there is
other (plain) data. So can keep the archive seekable. However apparently
this doesn't work out as it should. Whenever gzip_decompressor reaches
the end of a chunk it throws an exception. The trouble-making line is in
basic_gzip_decompressor::read:

if (footer_.done()) {
   if (footer_.crc() != this->crc())
     boost::throw_exception(gzip_error(gzip::bad_crc));
   int c = boost::iostreams::get(peek);
   if (traits_type::is_eof(c)) {
   -----------------------------
     state_ = s_done;
   } else {
     peek.putback(c);
     base_type::close(peek, BOOST_IOS::in);
     state_ = s_start;
     header_.reset();
     footer_.reset();
   }
}

Thus after the footer is read and checked, the decompressor checks
whether or not eof is reached. Obvisiously this isn't the case here -
the decompressed chunk is just embedded in the file. Thus the
decompressor restarts, but cannot find another header thus throwing an
exception.
Would it be reasonable to just insert a break?

     header_.reset();
     footer_.reset();
+ break;
   }
}

This would solve _my_ problem. Or is there another way to work around
this issue?

Best Olaf


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