aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2004-06-24 14:06:22 +0000
committerEugene Sandulenko2004-06-24 14:06:22 +0000
commit264dc1349bc1f61c5f27383d4293b4c2dcf34b87 (patch)
tree2a9110a71ac4ad6232e7ff7fa3d6442caaa054d4
parentafbe1efa1821ab9710d9b66501cbc89d6aab3778 (diff)
downloadscummvm-rg350-264dc1349bc1f61c5f27383d4293b4c2dcf34b87.tar.gz
scummvm-rg350-264dc1349bc1f61c5f27383d4293b4c2dcf34b87.tar.bz2
scummvm-rg350-264dc1349bc1f61c5f27383d4293b4c2dcf34b87.zip
Extended ReadMemoryStream class with seek method
svn-id: r14030
-rw-r--r--common/stream.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/stream.h b/common/stream.h
index d30fa63a6d..3b6d7a8d34 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -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