Got rid of ReadStream::ioFailed()

svn-id: r46379
This commit is contained in:
Max Horn 2009-12-15 08:18:57 +00:00
parent eb9b31782f
commit f692015301
9 changed files with 19 additions and 25 deletions

View File

@ -176,12 +176,6 @@ public:
// The remaining methods all have default implementations; subclasses
// in general should not overload them.
/**
* DEPRECATED
* Default implementation for backward compatibility
*/
inline bool ioFailed() { return (eos() || err()); }
/**
* Read an unsigned byte from the stream and return it.
* Performs no error checking. The return value is undefined

View File

@ -36,13 +36,13 @@
namespace Sci {
int Decompressor::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked) {
uint32 chunk;
while (nPacked && !src->ioFailed()) {
while (nPacked && !(src->eos() || src->err())) {
chunk = MIN<uint32>(1024, nPacked);
src->read(dest, chunk);
nPacked -= chunk;
dest += chunk;
}
return src->ioFailed() ? 1 : 0;
return (src->eos() || src->err()) ? 1 : 0;
}
void Decompressor::init(Common::ReadStream *src, byte *dest, uint32 nPacked,

View File

@ -1016,7 +1016,7 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {
id = file.readUint16LE();
offset = file.readUint32LE();
if (file.ioFailed()) {
if (file.eos() || file.err()) {
warning("Error while reading %s", map->location_name.c_str());
return SCI_ERROR_RESMAP_NOT_FOUND;
}
@ -1095,7 +1095,7 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
// in SCI32 it's a plain offset
}
}
if (file.ioFailed()) {
if (file.eos() || file.err()) {
warning("Error while reading %s", map->location_name.c_str());
return SCI_ERROR_RESMAP_NOT_FOUND;
}
@ -1278,7 +1278,7 @@ int ResourceManager::readAudioMapSCI1(ResourceSource *map, bool unload) {
uint32 offset = file.readUint32LE();
uint32 size = file.readUint32LE();
if (file.ioFailed()) {
if (file.eos() || file.err()) {
warning("Error while reading %s", map->location_name.c_str());
return SCI_ERROR_RESMAP_NOT_FOUND;
}
@ -1405,7 +1405,7 @@ int ResourceManager::readResourceInfo(Resource *res, Common::File *file,
return SCI_ERROR_INVALID_RESMAP_ENTRY;
}
// check if there were errors while reading
if (file->ioFailed())
if ((file->eos() || file->err()))
return SCI_ERROR_IO_ERROR;
res->id = ResourceId(type, number);
res->size = szUnpacked;

View File

@ -133,7 +133,7 @@ void SetupHandleTable() {
handleTable[i].flags2 = t2Flag ? f.readUint32LE() : 0;
}
if (f.ioFailed()) {
if (f.eos() || f.err()) {
// index file is corrupt
error(FILE_IS_CORRUPT, (TinselV1PSX? PSX_INDEX_FILENAME : INDEX_FILENAME));
}

View File

@ -370,7 +370,7 @@ void OpenMidiFiles() {
// gen length of the largest sequence
midiBuffer.size = midiStream.readUint32LE();
if (midiStream.ioFailed())
if (midiStream.eos() || midiStream.err())
error(FILE_IS_CORRUPT, MIDI_FILE);
if (midiBuffer.size) {
@ -860,7 +860,7 @@ bool PCMMusicPlayer::getNextChunk() {
error(CANNOT_FIND_FILE, _fileName);
file.seek(sampleOffset);
if (file.ioFailed() || (uint32)file.pos() != sampleOffset)
if (file.eos() || file.err() || (uint32)file.pos() != sampleOffset)
error(FILE_IS_CORRUPT, _fileName);
buffer = (byte *) malloc(sampleCLength);

View File

@ -406,7 +406,7 @@ void RegisterGlobals(int num) {
for (int i = 0; i < length; ++i)
pGlobals[i] = f.readSint32LE();
if (f.ioFailed())
if (f.eos() || f.err())
error(FILE_IS_CORRUPT, GLOBALS_FILENAME);
f.close();

View File

@ -467,7 +467,7 @@ static bool DoRestore() {
if (id != (uint32)0xFEEDFACE)
error("Incompatible saved game");
bool failed = f->ioFailed();
bool failed = (f->eos() || f->err());
delete f;

View File

@ -98,12 +98,12 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
// move to correct position in the sample file
_sampleStream.seek(dwSampleIndex);
if (_sampleStream.ioFailed() || (uint32)_sampleStream.pos() != dwSampleIndex)
if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex)
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
// read the length of the sample
uint32 sampleLen = _sampleStream.readUint32LE();
if (_sampleStream.ioFailed())
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
if (TinselV1PSX) {
@ -244,12 +244,12 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
// move to correct position in the sample file
_sampleStream.seek(dwSampleIndex);
if (_sampleStream.ioFailed() || (uint32)_sampleStream.pos() != dwSampleIndex)
if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex)
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
// read the length of the sample
uint32 sampleLen = _sampleStream.readUint32LE();
if (_sampleStream.ioFailed())
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
if (sampleLen & 0x80000000) {
@ -263,11 +263,11 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
for (int32 i = 0; i < sub; i++) {
sampleLen = _sampleStream.readUint32LE();
_sampleStream.skip(sampleLen);
if (_sampleStream.ioFailed())
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
}
sampleLen = _sampleStream.readUint32LE();
if (_sampleStream.ioFailed())
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
}
@ -553,7 +553,7 @@ void SoundManager::openSampleFiles() {
/*
// gen length of the largest sample
sampleBuffer.size = _sampleStream.readUint32LE();
if (_sampleStream.ioFailed())
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
*/
}

View File

@ -112,7 +112,7 @@ void ChangeLanguage(LANGUAGE newLang) {
// first long is the filelength and for uncompressed files it is the chunk
// identifier
textLen = f.readUint32LE();
if (f.ioFailed())
if (f.eos() || f.err())
error(FILE_IS_CORRUPT, _vm->getTextFile(newLang));
if (textLen == CHUNK_STRING || textLen == CHUNK_MBSTRING) {