[Scummvm-cvs-logs] SF.net SVN: scummvm:[34562] scummvm/trunk/backends/saves/compressed/ compressed-saves.cpp

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Mon Sep 15 21:19:37 CEST 2008


Revision: 34562
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34562&view=rev
Author:   wjpalenstijn
Date:     2008-09-15 19:19:30 +0000 (Mon, 15 Sep 2008)

Log Message:
-----------
fix eos() behaviour for CompressedInSaveFile

Modified Paths:
--------------
    scummvm/trunk/backends/saves/compressed/compressed-saves.cpp

Modified: scummvm/trunk/backends/saves/compressed/compressed-saves.cpp
===================================================================
--- scummvm/trunk/backends/saves/compressed/compressed-saves.cpp	2008-09-15 14:35:11 UTC (rev 34561)
+++ scummvm/trunk/backends/saves/compressed/compressed-saves.cpp	2008-09-15 19:19:30 UTC (rev 34562)
@@ -52,6 +52,7 @@
 	int _zlibErr;
 	uint32 _pos;
 	uint32 _origSize;
+	bool _eos;
 
 public:
 
@@ -78,6 +79,7 @@
 		}
 		_pos = 0;
 		w->seek(0, SEEK_SET);
+		_eos = false;
 
 		// Adding 32 to windowBits indicates to zlib that it is supposed to
 		// automatically detect whether gzip or zlib headers are used for
@@ -99,7 +101,10 @@
 	}
 
 	bool err() const { return (_zlibErr != Z_OK) && (_zlibErr != Z_STREAM_END); }
-	void clearErr() { /* errors here are not recoverable!  */ }
+	void clearErr() {
+		// only reset _eos; I/O errors are not recoverable
+		_eos = false;
+	}
 
 	uint32 read(void *dataPtr, uint32 dataSize) {
 		_stream.next_out = (byte *)dataPtr;
@@ -118,12 +123,14 @@
 		// Update the position counter
 		_pos += dataSize - _stream.avail_out;
 
+		if (_zlibErr == Z_STREAM_END && _stream.avail_out > 0)
+			_eos = true;
+
 		return dataSize - _stream.avail_out;
 	}
 
 	bool eos() const {
-		return (_zlibErr == Z_STREAM_END);
-		//return _pos == _origSize;
+		return _eos;
 	}
 	int32 pos() const {
 		return _pos;
@@ -170,6 +177,7 @@
 			offset -= read(tmpBuf, MIN((int32)sizeof(tmpBuf), offset));
 		}
 		
+		_eos = false;
 		return true;	// FIXME: STREAM REWRITE
 	}
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list