From f58abd95409998d5e0859aaa1ef0df14c0639519 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 4 Aug 2016 15:14:06 +0600 Subject: COMMON: Update GZipWriteStream::pos() Though it seemed the _wrapped stream should return valid position, it was always 0. That's why I've added a _pos field, which is updated in write() and returned in pos(). --- common/zlib.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/zlib.cpp b/common/zlib.cpp index 3b51d66a5b..39130beb4e 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -316,6 +316,7 @@ protected: ScopedPtr _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,10 +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 _wrapped->pos(); } + virtual int32 pos() const { return _pos; } }; #endif // USE_ZLIB -- cgit v1.2.3