aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-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.cpp6
6 files changed, 21 insertions, 3 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..39130beb4e 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -316,6 +316,7 @@ protected:
ScopedPtr<WriteStream> _wrapped;
z_stream _stream;
int _zlibErr;
+ uint32 _pos;
void processData(int flushType) {
// This function is called by both write() and finalize().
@@ -333,7 +334,7 @@ protected:
}
public:
- GZipWriteStream(WriteStream *w) : _wrapped(w), _stream() {
+ GZipWriteStream(WriteStream *w) : _wrapped(w), _stream(), _pos(0) {
assert(w != 0);
// Adding 16 to windowBits indicates to zlib that it is supposed to
@@ -403,8 +404,11 @@ public:
// ... and flush it to disk
processData(Z_NO_FLUSH);
+ _pos += dataSize - _stream.avail_in;
return dataSize - _stream.avail_in;
}
+
+ virtual int32 pos() const { return _pos; }
};
#endif // USE_ZLIB