[Scummvm-devel] ScummVM PS2 backend - to be or not to be... a directory

sunmax at libero.it sunmax at libero.it
Tue Feb 19 16:48:17 CET 2008


Aaaaaaarrrrgggghhhhh :-(

Ok. Cool down. One simple question:

which is the right way on the PS2, given a "path", to make out
if that is a directory or not?

Posix 'access', 'stat' and friends are just stub in PS2SDK so
they won't really help to see if something exists or it is a
directory.

My simple idea was to use fio.dopen(path.c_str()) and then if it fails
to set _isDirectory to false. It nearly works. "Nearly". In the cases
where it succeeds [e.g. >= 0] (which I assume being the directories)
I am closing the fd with fio.dclose(fd). It seems so easy but...

...as soon as I do that dclose everything (fs related) goes berserk,
cause I start losing nodes, not internally in the ScummVM but the fioX
is no longer able to open some files that it was able to open before
that 'dclose'. You can see that's the case cause if we just comment
the dclose out, everything goes. Kind of. in Asyncio We just have 32
file descriptors (if I got it right), so it wouldn't get far with games
with many resources...

It seems that my dclose is not context safe, and is corrupting something.

The goal is to have:

Ps2FilesystemNode::Ps2FilesystemNode(const String &path, bool verify);

implemented in the way PSP does.

My current implementation is a plain copy of the original
Ps2FilesystemNode::Ps2FilesystemNode(const String &path)
plus the following lines at the end.

    if (verify && !_isRoot) {
        int fd = fio.dopen(path.c_str());
        if (fd < 0) {
            _isDirectory = false;
        }
        else {
            fio.dclose(fd);
        }
    }

It does not seem they should harm, don't they?

>From the factory we are doing: return new Ps2FilesystemNode(path, true);

I even tried moving it out from the constructor, but does not help.
As soon as I dclose the valid FD, sayonara.

Following dopen will return -24.

  FIO: dopen(mass:/scummvm/bs2-demo/) => -24

Robert, with your greater PS2 experience, do you spot anything wrong?
I tried using your IRXs too, but does not help. I will try rebuilding
an older toolchain/ps2sdk later as well.

 (NOTE: it's the same whichever medium I am using: HD, USB, CD)

Thanks!
 -max





More information about the Scummvm-devel mailing list