mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 08:17:40 +00:00
Extended ReadMemoryStream class with seek method
svn-id: r14030
This commit is contained in:
parent
afbe1efa18
commit
264dc1349b
@ -143,6 +143,35 @@ public:
|
||||
_size = _sizeOrig;
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
void seek(uint32 offs, int whence = SEEK_SET) {
|
||||
switch (whence) {
|
||||
case SEEK_SET:
|
||||
rewind();
|
||||
if (offs > _size)
|
||||
offs = _size;
|
||||
_size -= offs;
|
||||
_ptr += offs;
|
||||
_pos += offs;
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
_size -= offs;
|
||||
_ptr += offs;
|
||||
_pos += offs;
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
rewind();
|
||||
if (offs > _size)
|
||||
offs = 0;
|
||||
offs = _size - offs;
|
||||
_size -= offs;
|
||||
_ptr += offs;
|
||||
_pos += offs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // End of namespace Common
|
||||
|
Loading…
Reference in New Issue
Block a user