Logo Search packages:      
Sourcecode: djvulibre version File versions

size_t ByteStream::copy ( ByteStream bsfrom,
size_t  size = 0 
) [inherited]

Copy data from another ByteStream. A maximum of size# bytes are read from the ByteStream bsfrom# and are written to the ByteStream #*this# at the current position. Less than size# bytes may be written if an end-of-file mark is reached on bsfrom#. This function returns the total number of bytes copied. Setting argument size# to zero (the default value) has a special meaning: the copying process will continue until reaching the end-of-file mark on ByteStream bsfrom#, regardless of the number of bytes transferred.

Reimplemented in IFFByteStream.

Definition at line 467 of file ByteStream.cpp.

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

Referenced by DjVuDocEditor::save_as(), DjVuDocument::write(), and DjVuImage::writeXML().

  size_t total = 0;
  const size_t max_buffer_size=200*1024;
  const size_t buffer_size=(size>0 && size<max_buffer_size)
  char *buffer;
  GPBuffer<char> gbuf(buffer,buffer_size);
      size_t bytes = buffer_size;
      if (size>0 && bytes+total>size)
        bytes = size - total;
      if (bytes == 0)
      bytes = bsfrom.read((void*)buffer, bytes);
      if (bytes == 0)
      writall((void*)buffer, bytes);
      total += bytes;
  return total;

Generated by  Doxygen 1.6.0   Back to index