Added seek() method to MemoryWriteStreamDynamic.

If it deserves a separate class, shout.

svn-id: r49750
This commit is contained in:
Eugene Sandulenko 2010-06-15 10:34:14 +00:00
parent 38ef876d5b
commit 024f492137
2 changed files with 27 additions and 0 deletions

View file

@ -303,4 +303,29 @@ bool BufferedSeekableReadStream::seek(int32 offset, int whence) {
return true; // FIXME: STREAM REWRITE
}
bool MemoryWriteStreamDynamic::seek(int32 offs, int whence) {
// Pre-Condition
assert(_pos <= _size);
switch (whence) {
case SEEK_END:
// SEEK_END works just like SEEK_SET, only 'reversed',
// i.e. from the end.
offs = _size + offs;
// Fall through
case SEEK_SET:
_ptr = _data + offs;
_pos = offs;
break;
case SEEK_CUR:
_ptr += offs;
_pos += offs;
break;
}
// Post-Condition
assert(_pos <= _size);
return true; // FIXME: STREAM REWRITE
}
} // End of namespace Common

View file

@ -687,6 +687,8 @@ public:
uint32 size() const { return _size; }
byte *getData() { return _data; }
bool seek(int32 offset, int whence = SEEK_SET);
};
} // End of namespace Common