aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-08-04 14:36:21 +0600
committerAlexander Tkachev2016-08-04 14:36:21 +0600
commit7a89caac84d2dd8cb987b20f432609d462a5f5d8 (patch)
tree5c41845a0d36cd78d487a3a1c062ebcfa27d5a0e
parentc34af3993771db881b27ebdbdd4d531cbc9c48b4 (diff)
downloadscummvm-rg350-7a89caac84d2dd8cb987b20f432609d462a5f5d8.tar.gz
scummvm-rg350-7a89caac84d2dd8cb987b20f432609d462a5f5d8.tar.bz2
scummvm-rg350-7a89caac84d2dd8cb987b20f432609d462a5f5d8.zip
COMMON: Add WriteStream::pos()
It returns int32, because some complex streams are derived from both WriteStream and ReadStream, and in ReadStream pos() returns int32, because -1 means an error. I had to change MemoryStream's uint32 to int32, which is probably not so good.
-rw-r--r--common/file.cpp2
-rw-r--r--common/file.h2
-rw-r--r--common/memstream.h4
-rw-r--r--common/stream.cpp2
-rw-r--r--common/stream.h8
-rw-r--r--common/zlib.cpp2
6 files changed, 18 insertions, 2 deletions
diff --git a/common/file.cpp b/common/file.cpp
index 16e6a0df1a..4d9c630076 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -202,4 +202,6 @@ bool DumpFile::flush() {
return _handle->flush();
}
+int32 DumpFile::pos() const { return _handle->pos(); }
+
} // End of namespace Common
diff --git a/common/file.h b/common/file.h
index c055acc57d..3d174834e9 100644
--- a/common/file.h
+++ b/common/file.h
@@ -161,6 +161,8 @@ public:
virtual uint32 write(const void *dataPtr, uint32 dataSize);
virtual bool flush();
+
+ virtual int32 pos() const;
};
} // End of namespace Common
diff --git a/common/memstream.h b/common/memstream.h
index 94407f5cc9..59d5f15b1a 100644
--- a/common/memstream.h
+++ b/common/memstream.h
@@ -111,7 +111,7 @@ public:
return dataSize;
}
- uint32 pos() const { return _pos; }
+ int32 pos() const { return _pos; }
uint32 size() const { return _bufSize; }
virtual bool err() const { return _err; }
@@ -201,7 +201,7 @@ public:
return dataSize;
}
- uint32 pos() const { return _pos; }
+ int32 pos() const { return _pos; }
uint32 size() const { return _size; }
byte *getData() { return _data; }
diff --git a/common/stream.cpp b/common/stream.cpp
index 45060b9db5..a8446a9086 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -500,6 +500,8 @@ public:
virtual bool flush() { return flushBuffer(); }
+ virtual int32 pos() const { return _pos; }
+
};
} // End of anonymous namespace
diff --git a/common/stream.h b/common/stream.h
index abe5192b70..c6c300fa97 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -103,6 +103,14 @@ public:
flush();
}
+ /**
+ * Obtains the current value of the stream position indicator of the
+ * stream.
+ *
+ * @return the current position indicator, or -1 if an error occurred.
+ */
+ virtual int32 pos() const = 0;
+
// The remaining methods all have default implementations; subclasses
// need not (and should not) overload them.
diff --git a/common/zlib.cpp b/common/zlib.cpp
index c22ea1e660..3b51d66a5b 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -405,6 +405,8 @@ public:
return dataSize - _stream.avail_in;
}
+
+ virtual int32 pos() const { return _wrapped->pos(); }
};
#endif // USE_ZLIB