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

int ByteStream::Stdio::seek ( long  offset,
int  whence = SEEK_SET,
bool  nothrow = false 
) [virtual]

Sets the current position for reading or writing the ByteStream. Class ByteStream# provides a default implementation able to seek forward by calling function read# until reaching the desired position. Subclasses implementing better seek capabilities must override this default implementation. The new current position is computed by applying displacement offset# to the position represented by argument whence#. The following values are recognized for argument whence#: {description} [SEEK_SET#] Argument offset# indicates the position relative to the beginning of the ByteStream. [SEEK_CUR#] Argument offset# is a signed displacement relative to the current position. [SEEK_END#] Argument offset# is a displacement relative to the end of the file. It is then advisable to provide a negative value for offset#. {description} Results are undefined whenever the new position is greater than the total size of the ByteStream.

{ Error reporting}: If seek()# succeeds, #0# is returned. Otherwise it either returns #-1# (if nothrow# is set to FALSE#) or throws the {GException} exception.

Reimplemented from ByteStream.

Definition at line 772 of file ByteStream.cpp.

References tell().

  if (whence==SEEK_SET && offset>=0 && offset==ftell(fp))
    return 0;
  if (fseek(fp, offset, whence)) 
      if (nothrow) 
        return -1;
      G_THROW(strerror(errno)); //  (No error in the DjVuMessageFile)
  return tell();

Generated by  Doxygen 1.6.0   Back to index