[Scummvm-cvs-logs] scummvm master -> 7a89caac84d2dd8cb987b20f432609d462a5f5d8

Tkachov Tkachov at users.noreply.github.com
Thu Aug 4 09:38:37 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
7a89caac84 COMMON: Add WriteStream::pos()


Commit: 7a89caac84d2dd8cb987b20f432609d462a5f5d8
    https://github.com/scummvm/scummvm/commit/7a89caac84d2dd8cb987b20f432609d462a5f5d8
Author: Alexander Tkachev (alexander at tkachov.ru)
Date: 2016-08-04T14:36:21+06:00

Commit Message:
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.

Changed paths:
    common/file.cpp
    common/file.h
    common/memstream.h
    common/stream.cpp
    common/stream.h
    common/zlib.cpp



diff --git a/common/file.cpp b/common/file.cpp
index 16e6a0d..4d9c630 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 c055acc..3d17483 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 94407f5..59d5f15 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 45060b9..a8446a9 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 abe5192..c6c300f 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 c22ea1e..3b51d66 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






More information about the Scummvm-git-logs mailing list