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

size_t ByteStream::Stdio::write ( const void *  buffer,
size_t  size 
) [virtual]

Writes data to a ByteStream. This function {must} be implemented by each subclass of ByteStream#. At most size# bytes from buffer buffer# are written to the ByteStream. Function write# returns immediately if size# is zero. The actual number of bytes written is returned. Function write# 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 {writall}. Exception {GException} is thrown with a plain text error message whenever an error occurs.

Reimplemented from ByteStream.

Definition at line 723 of file ByteStream.cpp.

{
  if (!can_write)
    G_THROW( ERR_MSG("ByteStream.no_write") ); //  Stdio not opened for writing
  size_t nitems;
  do
  {
    clearerr(fp);
    nitems = fwrite(buffer, 1, size, fp);
    if (nitems<=0 && ferror(fp))
    {
#ifdef EINTR
      if (errno!=EINTR)
#endif
        G_THROW(strerror(errno)); //  (No error in the DjVuMessageFile)
    }
    else
      break;
  } while(true);
  pos += nitems;
  return nitems;
}

Generated by  Doxygen 1.6.0   Back to index