aboutsummaryrefslogtreecommitdiff
path: root/common/stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/stream.cpp')
-rw-r--r--common/stream.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/common/stream.cpp b/common/stream.cpp
index 6737eafc9c..84b712a562 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -152,7 +152,7 @@ char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
len++;
}
- // We always terminate the buffer if no error occured
+ // We always terminate the buffer if no error occurred
*p = 0;
return buf;
}
@@ -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