diff options
author | Willem Jan Palenstijn | 2008-09-14 22:28:53 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2008-09-14 22:28:53 +0000 |
commit | c8eeae8d4dffa5849a23cf963884027a7789504b (patch) | |
tree | 1f2a0de23851cb7e7d1d77114c8379aa27f4fb85 /backends/saves/compressed | |
parent | fbfe30bf861af9b83325e0c7fecd4b0a68da5af9 (diff) | |
download | scummvm-rg350-c8eeae8d4dffa5849a23cf963884027a7789504b.tar.gz scummvm-rg350-c8eeae8d4dffa5849a23cf963884027a7789504b.tar.bz2 scummvm-rg350-c8eeae8d4dffa5849a23cf963884027a7789504b.zip |
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
Diffstat (limited to 'backends/saves/compressed')
-rw-r--r-- | backends/saves/compressed/compressed-saves.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
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 ... |