0

Thanks Mark, on resumption, now I get Z_DATA_ERROR

case STORED:
   strm->msg = (char *)"invalid stored block lengths";  // got here - Anton
   state->mode = BAD;

Just to see I understood your suggestions yesterday:

after inflateInit2()

// go to byte offset
ZSEEK64( , , streamCurrentPos, ZLIB_FILEFUNC_SEEK_SET)

if ( streamBits > 0 ) 
{
   // get that byte
   unz64local_getByte( , , &aByte)
   
   // and shift down by the number of bits. This API doing it? 
   inflatePrime ( , streamBits, 8 - streamBits)
   
} else { no bits to insert }

inflateSetDictionary ()

And state of uncompression is saved like this:

typedef struct state_of_uncompression
{

  ZPOS64_T streamCurrentPos;      // from : unzGetCurrentFileZStreamPos64()
  int      streamBits;            // from : stream.data_type & (~0x1C0), after clearing bits 8,7, and 6
  Byte     dictionary_buf[32768]; // from : inflateGetDictionary()
  uInt     dictLength;            // from : inflateGetDictionary();
  uint64_t output_wrt_offset      // got this already. 

} uncompression_state_info;
  • Please don't put pseudo-code in your questions, e.g. with missing parameters. Copy and paste the actual code. – Mark Adler Nov 29 '22 at 00:12

1 Answers1

0

What? No.

inflatePrime ( , streamBits, 8 - streamBits) makes no sense. And you did nothing with the aByte you got.

It should be inflatePrime(strm, streamBits, aByte >> (8 - streamBits)).

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • Thanks Mark, with the correction to inflatePrime() call, I noticed my 'state->last' is getting set in the first call to inflate() on resumption. NEEDBITS(3); state->last = BITS(1); // last is set And got here also: strm->msg = (char *)"invalid code lengths set"; And the aByte was: unz64local_getByte() OK, aByte = 0x000000D7 All this looks like, my seek is not correct, for inflate() to restart from the correct offset. I will check after seek, if my current pos/offset in the compressed data is same as before reboot, i.e saved-streamCurrentPos. Thanks. – Anton Fernando Nov 29 '22 at 15:02