Logo Search packages:      
Sourcecode: djvulibre version File versions

size_t IFFByteStream::read ( void *  buffer,
size_t  size 
) [virtual]

Reads data from a ByteStream. This function {must} be implemented by each subclass of ByteStream#. At most size# bytes are read from the ByteStream and stored in the memory area pointed to by buffer#. Function read# returns immediately if size# is zero. The actual number of bytes read is returned. Function read# returns a number of bytes smaller than size# if the end-of-file mark is reached before filling the buffer. Subsequent invocations will always return value #0#. Function read# may also return a value greater than zero but smaller than size# for internal reasons. Programs must be ready to handle these cases or use function {readall}. Exception {GException} is thrown with a plain text error message whenever an error occurs.

Reimplemented from ByteStream::Wrapper.

Definition at line 469 of file IFFByteStream.cpp.

References ByteStream::read(), and ByteStream::seek().

Referenced by compare(), and DjVuFile::unlink_file().

  if (! (ctx && dir < 0))
    G_THROW( ERR_MSG("IFFByteStream.not_ready3") );
  // Seek if necessary
  if (seekto > offset) {
    offset = seekto;
  // Ensure that read does not extend beyond chunk
  if (offset > ctx->offEnd)
    G_THROW( ERR_MSG("IFFByteStream.bad_offset") );
  if (offset + (long)size >  ctx->offEnd)
    size = (size_t) (ctx->offEnd - offset);
  // Read bytes
  size_t bytes = bs->read(buffer, size);
  offset += bytes;
  return bytes;

Generated by  Doxygen 1.6.0   Back to index