[Scummvm-devel] eof & err

sunmax at libero.it sunmax at libero.it
Sun Jul 12 21:29:04 CEST 2009


Eh, eh,

my telepathic friends. We crossed-mail ;-)

> > That code is _before_ reading, though, so that should be ok.
> 
> Correction: kyra does a couple of reads of length 0.

Then in this case, since we are trying to read past the end,
(even if I am not sure how to interpret the "length 0" case,
btw: why are we doing this?) we should set _eof.

And then if err() is supposed to return true on _eof (can
somebody confirm this?), it should return true causing
kyra to exit.


> What happens if you just remove that check?

> The length>0 cases should be covered by the check after it.

Yes.

But the following check is to trim down a read past the end
which is still partially successful (e.g. file size = 64,
file pos = 40, len = 32 - it will let you read just 24 bytes
and set _eof)

The first is to bail out when the end has already been reached
and you keep trying to read.

Our goal here should not only be to keep kyra happy but to find
out the correct semantics for eof/eos/err, so that all engines
will properly behave on top of the PS2 files implementation.

Quoting Johannes:

>> The specific bugged code doing a read of 0 bytes is:
>>
>> // eats up all the remaining data in the chunk
>> while (!stream.eos()) {
>>  stream.readByte();
>> }

Correct.

>> in common/iff_parser.h l293. Since SubReadStream relies on the
>> parent streams eos, in this case a StdioStream, either 
>> StdioStream::eos is bugged or there's a little bug in
>> SubReadStream.

Can one of the FS / Stream gurus have a loot into that?

At the moment we have a "hack" in place on the PS2 backend where
we just return "false" on ps2_ferror(). It does not affect other
engines (at least the few I tries) but it's still an ugly hack ;-)

Thanks!
 -max





More information about the Scummvm-devel mailing list