[Scummvm-cvs-logs] scummvm master -> 966ce6b413c0b29ef66673c6315fb3641ce113f9
lordhoto
lordhoto at gmail.com
Wed Jul 18 15:41:00 CEST 2012
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b398dcabaf COMMON: Add an optional argument to wrapCompressedReadStream, to simplify using streams that can't tell their size()
966ce6b413 Merge pull request #259 from somaen/zlib_knownSize
Commit: b398dcabaffbbc53d24d296fed3f64b0b8ecd519
https://github.com/scummvm/scummvm/commit/b398dcabaffbbc53d24d296fed3f64b0b8ecd519
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2012-07-18T04:54:15-07:00
Commit Message:
COMMON: Add an optional argument to wrapCompressedReadStream, to simplify using streams that can't tell their size()
Changed paths:
common/zlib.cpp
common/zlib.h
diff --git a/common/zlib.cpp b/common/zlib.cpp
index 7d765fc..76e3448 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -107,7 +107,7 @@ protected:
public:
- GZipReadStream(SeekableReadStream *w) : _wrapped(w), _stream() {
+ GZipReadStream(SeekableReadStream *w, uint32 knownSize = 0) : _wrapped(w), _stream() {
assert(w != 0);
// Verify file header is correct
@@ -122,7 +122,8 @@ public:
_origSize = w->readUint32LE();
} else {
// Original size not available in zlib format
- _origSize = 0;
+ // use an otherwise known size if supplied.
+ _origSize = knownSize;
}
_pos = 0;
w->seek(0, SEEK_SET);
@@ -336,7 +337,7 @@ public:
#endif // USE_ZLIB
-SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped) {
+SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize) {
#if defined(USE_ZLIB)
if (toBeWrapped) {
uint16 header = toBeWrapped->readUint16BE();
@@ -345,7 +346,7 @@ SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped) {
header % 31 == 0));
toBeWrapped->seek(-2, SEEK_CUR);
if (isCompressed)
- return new GZipReadStream(toBeWrapped);
+ return new GZipReadStream(toBeWrapped, knownSize);
}
#endif
return toBeWrapped;
diff --git a/common/zlib.h b/common/zlib.h
index 61322c2..8372499 100644
--- a/common/zlib.h
+++ b/common/zlib.h
@@ -86,10 +86,18 @@ bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen,
* format. In the former case, the original stream is returned unmodified
* (and in particular, not wrapped).
*
+ * Certain GZip-formats don't supply an easily readable length, if you
+ * still need the length carried along with the stream, and you know
+ * the decompressed length at wrap-time, then it can be supplied as knownSize
+ * here. knownSize will be ignored if the GZip-stream DOES include a length.
+ *
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
+ *
+ * @param toBeWrapped the stream to be wrapped (if it is in gzip-format)
+ * @param knownSize a supplied length of the compressed data (if not available directly)
*/
-SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped);
+SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize = 0);
/**
* Take an arbitrary WriteStream and wrap it in a custom stream which provides
Commit: 966ce6b413c0b29ef66673c6315fb3641ce113f9
https://github.com/scummvm/scummvm/commit/966ce6b413c0b29ef66673c6315fb3641ce113f9
Author: Johannes Schickel (lordhoto at gmail.com)
Date: 2012-07-18T06:39:57-07:00
Commit Message:
Merge pull request #259 from somaen/zlib_knownSize
COMMON: Add an argument to wrapCompressedReadStream, for streams with unknown size()
Changed paths:
common/zlib.cpp
common/zlib.h
More information about the Scummvm-git-logs
mailing list