From c8eeae8d4dffa5849a23cf963884027a7789504b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 14 Sep 2008 22:28:53 +0000 Subject: Big patch changing semantics of ReadStream::eos(): eos() now only returns true _after_ trying to read past the end of the stream. This has a large potential for regressions. Please test! svn-id: r34549 --- backends/saves/compressed/compressed-saves.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'backends/saves/compressed/compressed-saves.cpp') diff --git a/backends/saves/compressed/compressed-saves.cpp b/backends/saves/compressed/compressed-saves.cpp index 27b8749911..000fec9553 100644 --- a/backends/saves/compressed/compressed-saves.cpp +++ b/backends/saves/compressed/compressed-saves.cpp @@ -98,8 +98,8 @@ public: delete _wrapped; } - bool ioFailed() const { return (_zlibErr != Z_OK) && (_zlibErr != Z_STREAM_END); } - void clearIOFailed() { /* errors here are not recoverable! */ } + bool err() const { return (_zlibErr != Z_OK) && (_zlibErr != Z_STREAM_END); } + void clearErr() { /* errors here are not recoverable! */ } uint32 read(void *dataPtr, uint32 dataSize) { _stream.next_out = (byte *)dataPtr; @@ -166,7 +166,7 @@ public: // huge amounts of data, but usually client code will only skip a few // bytes, so this should be fine. byte tmpBuf[1024]; - while (!ioFailed() && offset > 0) { + while (!err() && offset > 0) { offset -= read(tmpBuf, MIN((int32)sizeof(tmpBuf), offset)); } @@ -236,14 +236,15 @@ public: delete _wrapped; } - bool ioFailed() const { - return (_zlibErr != Z_OK && _zlibErr != Z_STREAM_END) || _wrapped->ioFailed(); + bool err() const { + // CHECKME: does Z_STREAM_END make sense here? + return (_zlibErr != Z_OK && _zlibErr != Z_STREAM_END) || _wrapped->err(); } - void clearIOFailed() { + void clearErr() { // Note: we don't reset the _zlibErr here, as it is not - // clear in general ho - _wrapped->clearIOFailed(); + // clear in general how + _wrapped->clearErr(); } void finalize() { @@ -267,7 +268,7 @@ public: } uint32 write(const void *dataPtr, uint32 dataSize) { - if (ioFailed()) + if (err()) return 0; // Hook in the new data ... -- cgit v1.2.3