aboutsummaryrefslogtreecommitdiff
path: root/sys.cpp
diff options
context:
space:
mode:
authorEnrico Rolfi2002-03-09 13:51:37 +0000
committerEnrico Rolfi2002-03-09 13:51:37 +0000
commit19b42ea38e773698a388af51dd2b579acf97a34f (patch)
tree570643e864c6559be9a8dc3aa7352a730043ae2c /sys.cpp
parent1f7b48f6df264c55f1af7e8e4472b67fee27c99d (diff)
downloadscummvm-rg350-19b42ea38e773698a388af51dd2b579acf97a34f.tar.gz
scummvm-rg350-19b42ea38e773698a388af51dd2b579acf97a34f.tar.bz2
scummvm-rg350-19b42ea38e773698a388af51dd2b579acf97a34f.zip
clearerr added into disk reading operations to recover from wrong actions (which sometimes occurs)
svn-id: r3714
Diffstat (limited to 'sys.cpp')
-rw-r--r--sys.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys.cpp b/sys.cpp
index 80f2fdb519..044e80d340 100644
--- a/sys.cpp
+++ b/sys.cpp
@@ -62,7 +62,8 @@ uint32 Scumm::filePos(void *handle) {
void Scumm::fileSeek(void *file, long offs, int whence) {
switch(_fileMode) {
case 1: case 2:
- fseek((FILE*)file, offs, whence);
+ if (fseek((FILE*)file, offs, whence)!=0)
+ clearerr((FILE*)file);
return;
case 3:
_whereInResToRead = offs;
@@ -78,8 +79,10 @@ void Scumm::fileRead(void *file, void *ptr, uint32 size) {
if (size==0)
return;
- if ((uint32)fread(ptr2, size, 1, (FILE*)file) != 1)
+ if ((uint32)fread(ptr2, size, 1, (FILE*)file) != 1) {
+ clearerr((FILE*)file);
_fileReadFailed = true;
+ }
do {
*ptr2++ ^= _encbyte;
@@ -106,8 +109,10 @@ int Scumm::fileReadByte() {
switch(_fileMode) {
case 1:
- if (fread(&b,1,1,(FILE*)_fileHandle) != 1)
+ if (fread(&b,1,1,(FILE*)_fileHandle) != 1) {
+ clearerr((FILE*)_fileHandle);
_fileReadFailed = true;
+ }
return b ^ _encbyte;
case 3: