[Scummvm-devel] ReadStream::ioFailed/EOF - StdioStream::read

sunmax at libero.it sunmax at libero.it
Sun Feb 22 18:42:19 CET 2009


Hi there Willem,

> Currently the ::read in fileio.cpp never sets POS above SIZE,
> so simply checking POS > SIZE will not be a correct EOF check.

That's what I experienced. But Max (the good one, not me)
suggested to enforce that semantic (strictly >). Which I tried...

> Did you update that?

The original PS2 semantic was to raise EOF only when POS==SIZE,
in my branch I mimicked Ds, so I do when POS>=SIZE. Which kinda
works, -but- for unzip, indy4, etc. cause they test both for
"eos()" and "err()" in ioFailed. Unluckily if we have a semantic
where EOF = (POS >= SIZE), they will consider eos an error,
even if the read succeded :-(

> The way most other backends work is by keeping an eof flag that
> is set when reading past the end of the file.

Yes, I have that too now. This is what I used for PS2 ferror()
implementation. I tried to mirror EOF to it (eg. to return true,
only after the flag was set after an attempt to read beyond the
last byte) but this makes the loadConfig fail cause it relies
on EOF to be reported already when we read the last byte, as
you mentioned at the beginning POS > SIZE never succeeds.

I think I am going insane ;-)

Help!
 -max





More information about the Scummvm-devel mailing list