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

size_t ByteStream::Memory::readat ( void *  buffer,
size_t  sz,
int  pos 
) [protected, virtual]

Reads data from a random position. This function reads at most sz# bytes at position pos# into buffer# and returns the actual number of bytes read. The current position is unchanged.

Reimplemented from ByteStream.

Definition at line 874 of file ByteStream.cpp.

{
  if ((int) sz > bsize - pos)
    sz = bsize - pos;
  int nsz = (int)sz;
  if (nsz <= 0)
    return 0;
  // read data from buffer
  while (nsz > 0)
    {
      int n = (pos|0xfff) + 1 - pos;
      n = ((nsz < n) ? nsz : n);
      memcpy(buffer, (void*)&blocks[pos>>12][pos&0xfff], n);
      buffer = (void*) ((char*)buffer + n);
      pos += n;
      nsz -= n;
    }
  return sz;
}

Generated by  Doxygen 1.6.0   Back to index