aboutsummaryrefslogtreecommitdiff
path: root/common/stream.cpp
diff options
context:
space:
mode:
authorSven Hesse2011-05-05 21:37:48 +0200
committerSven Hesse2011-05-06 16:47:48 +0200
commit88d562a3615ad93af8dc2b0f40e28dc239108968 (patch)
treed2ab327fd2d46500cded935a8df44cf1102f6ac5 /common/stream.cpp
parentd77502eaf41b0bfc18fa22a23938e7d619f9e16c (diff)
downloadscummvm-rg350-88d562a3615ad93af8dc2b0f40e28dc239108968.tar.gz
scummvm-rg350-88d562a3615ad93af8dc2b0f40e28dc239108968.tar.bz2
scummvm-rg350-88d562a3615ad93af8dc2b0f40e28dc239108968.zip
COMMON: Add a class SafeSubReadStream
SafeSubReadStream is basically a SeekableSubReadStream that re-seek()s the parent stream before each read(). That way, more than one SafeSubReadStream of the same parent stream can be used safely at the same time, at the cost of increasing IO.
Diffstat (limited to 'common/stream.cpp')
-rw-r--r--common/stream.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/stream.cpp b/common/stream.cpp
index e870e68b2d..a785ac5164 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -242,6 +242,13 @@ bool SeekableSubReadStream::seek(int32 offset, int whence) {
return ret;
}
+uint32 SafeSubReadStream::read(void *dataPtr, uint32 dataSize) {
+ // Make sure the parent stream is at the right position
+ seek(0, SEEK_CUR);
+
+ return SeekableSubReadStream::read(dataPtr, dataSize);
+}
+
#pragma mark -