Logo Search packages:      
Sourcecode: pbzip2 version File versions  Download package

int pbzip2::BZ2StreamScanner::rewindInBuff (  ) [private]

Prepare for next read from file into input buffer. Consumes remaining input data buffer and moves header tail to beginning.

Copy end section of input buffer to beginning just in case the BZIP2 header is located between two buffer boundaries. Copy the other remaining data into output buffer.

Definition at line 245 of file BZ2StreamScanner.cpp.

{     
      // temporarily mark tail beginning (not real header position)
      _inBuffSearchPtr = getInBuffEnd() - ( _bz2Header.size() - 1 );
      int ret = appendOutBuffData();
      if ( failed() || ( ret < 0 ) )
      {
            return -1;
      }
      else if ( ret == 0 )
      {
            // search pos <= current
            _inBuffSearchPtr = getInBuffCurrent();
      }

      int tailSize = getInBuffEnd() - getInBuffSearchPtr();

      #ifdef PBZIP_DEBUG
      fprintf( stderr, " rewindInBuff: tail len: %d; app ret=%d [", tailSize, ret );
      printCurrentState();
      fprintf( stderr, "\n" );
      #endif

      // copy tail of input buffer to start and cut the rest
      std::copy( getInBuffSearchPtr(), getInBuffEnd(), getInBuffBegin() );
      _inBuffEnd = getInBuffBegin() + tailSize;
      _inBuffCurrent = getInBuffBegin();
      _inBuffSearchPtr = getInBuffBegin();

      #ifdef PBZIP_DEBUG
      fprintf( stderr, " end rewindInBuff: tail len: %d; app ret=%d [", tailSize, ret );
      printCurrentState();
      fprintf( stderr, "\n" );
      #endif

      return 0;
}

Generated by  Doxygen 1.6.0   Back to index