Logo Search packages:      
Sourcecode: pwlib version File versions

BOOL PMemoryFile::SetPosition ( off_t  pos,
FilePositionOrigin  origin = Start 
) [virtual]

Set the current active position in the file for the next read or write operation. The pos# variable is a signed number which is added to the specified origin. For origin == PFile::Start# only positive values for pos# are meaningful. For origin == PFile::End# only negative values for pos# are meaningful.

Returns:
TRUE if the new file position was set.
Parameters:
pos  New position to set.
origin  Origin for position change.

Reimplemented from PFile.

Definition at line 114 of file memfile.cxx.

References PFile::Current, PFile::End, and PFile::Start.

{
  switch (origin) {
    case Start:
      if (pos > data.GetSize())
        return FALSE;
      position = pos;
      break;

    case Current:
      if (pos < -position || pos > (data.GetSize() - position))
        return FALSE;
      position += pos;
      break;

    case End:
      if (pos < -data.GetSize())
        return FALSE;
      position = data.GetSize() - pos;
      break;
  }
  return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index