ScummFile: Don't use the File::_ioFailed flag, rather track the io status separately; also, changed eof() -> eos()
svn-id: r34389
This commit is contained in:
parent
f8bcb0782b
commit
088a1c0806
4 changed files with 12 additions and 8 deletions
|
@ -125,8 +125,8 @@ bool ScummFile::openSubFile(const Common::String &filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ScummFile::eof() {
|
bool ScummFile::eos() {
|
||||||
return _subFileLen ? (pos() >= _subFileLen) : File::eof();
|
return _subFileLen ? (pos() >= _subFileLen) : File::eos();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ScummFile::pos() {
|
uint32 ScummFile::pos() {
|
||||||
|
@ -167,7 +167,7 @@ uint32 ScummFile::read(void *dataPtr, uint32 dataSize) {
|
||||||
uint32 newPos = curPos + dataSize;
|
uint32 newPos = curPos + dataSize;
|
||||||
if (newPos > _subFileLen) {
|
if (newPos > _subFileLen) {
|
||||||
dataSize = _subFileLen - curPos;
|
dataSize = _subFileLen - curPos;
|
||||||
_ioFailed = true;
|
_myIoFailed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
virtual bool open(const Common::String &filename) = 0;
|
virtual bool open(const Common::String &filename) = 0;
|
||||||
virtual bool openSubFile(const Common::String &filename) = 0;
|
virtual bool openSubFile(const Common::String &filename) = 0;
|
||||||
|
|
||||||
virtual bool eof() = 0;
|
virtual bool eos() = 0;
|
||||||
virtual uint32 pos() = 0;
|
virtual uint32 pos() = 0;
|
||||||
virtual uint32 size() = 0;
|
virtual uint32 size() = 0;
|
||||||
virtual void seek(int32 offs, int whence = SEEK_SET) = 0;
|
virtual void seek(int32 offs, int whence = SEEK_SET) = 0;
|
||||||
|
@ -51,6 +51,7 @@ private:
|
||||||
byte _encbyte;
|
byte _encbyte;
|
||||||
uint32 _subFileStart;
|
uint32 _subFileStart;
|
||||||
uint32 _subFileLen;
|
uint32 _subFileLen;
|
||||||
|
bool _myIoFailed;
|
||||||
public:
|
public:
|
||||||
ScummFile();
|
ScummFile();
|
||||||
void setEnc(byte value);
|
void setEnc(byte value);
|
||||||
|
@ -61,7 +62,10 @@ public:
|
||||||
bool open(const Common::String &filename);
|
bool open(const Common::String &filename);
|
||||||
bool openSubFile(const Common::String &filename);
|
bool openSubFile(const Common::String &filename);
|
||||||
|
|
||||||
bool eof();
|
bool ioFailed() const { return _myIoFailed || BaseScummFile::ioFailed(); }
|
||||||
|
void clearIOFailed() { _myIoFailed = false; BaseScummFile::clearIOFailed(); }
|
||||||
|
|
||||||
|
bool eos();
|
||||||
uint32 pos();
|
uint32 pos();
|
||||||
uint32 size();
|
uint32 size();
|
||||||
void seek(int32 offs, int whence = SEEK_SET);
|
void seek(int32 offs, int whence = SEEK_SET);
|
||||||
|
@ -106,7 +110,7 @@ public:
|
||||||
bool openSubFile(const Common::String &filename);
|
bool openSubFile(const Common::String &filename);
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
bool eof() { return _stream->eos(); }
|
bool eos() { return _stream->eos(); }
|
||||||
uint32 pos() { return _stream->pos(); }
|
uint32 pos() { return _stream->pos(); }
|
||||||
uint32 size() { return _stream->size(); }
|
uint32 size() { return _stream->size(); }
|
||||||
void seek(int32 offs, int whence = SEEK_SET) { _stream->seek(offs, whence); }
|
void seek(int32 offs, int whence = SEEK_SET) { _stream->seek(offs, whence); }
|
||||||
|
|
|
@ -253,7 +253,7 @@ void ScummEngine::readIndexFile() {
|
||||||
|
|
||||||
if (_game.version <= 5) {
|
if (_game.version <= 5) {
|
||||||
// Figure out the sizes of various resources
|
// Figure out the sizes of various resources
|
||||||
while (!_fileHandle->eof()) {
|
while (!_fileHandle->eos()) {
|
||||||
blocktype = _fileHandle->readUint32BE();
|
blocktype = _fileHandle->readUint32BE();
|
||||||
itemsize = _fileHandle->readUint32BE();
|
itemsize = _fileHandle->readUint32BE();
|
||||||
if (_fileHandle->ioFailed())
|
if (_fileHandle->ioFailed())
|
||||||
|
|
|
@ -62,7 +62,7 @@ void ScummEngine_v4::readIndexFile() {
|
||||||
closeRoom();
|
closeRoom();
|
||||||
openRoom(0);
|
openRoom(0);
|
||||||
|
|
||||||
while (!_fileHandle->eof()) {
|
while (!_fileHandle->eos()) {
|
||||||
// Figure out the sizes of various resources
|
// Figure out the sizes of various resources
|
||||||
itemsize = _fileHandle->readUint32LE();
|
itemsize = _fileHandle->readUint32LE();
|
||||||
blocktype = _fileHandle->readUint16LE();
|
blocktype = _fileHandle->readUint16LE();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue