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

sunmax at libero.it sunmax at libero.it
Fri Feb 22 22:11:39 CET 2008


Hi there!


> Well, imagine when you just want to know whether "somefile.txt"  
> exists, without first getting a full list of all files in all search  
> dirs, and then scanning through that... ;)
> 
> And if a backend can provide a listing of all files in a directory,  
> it should also easily be able to tell whether a given file exists or  
> not, no?

Yes, if the directory exists ;-) It's a catch 22.

The difference is that the higher point (pfs0: mass: cdfs:) always
exist, so you can open it safely and get the childrens without losing fd
(we still have to figure if it this is a ps2link or a driver issue).

If you are trying to make out if a "somefile.txt" exists, scummvm will:

1) try pwd (i.e. just the filename), this currently -always- fails on ps2

2) try fullpath, this works but there is no 'access' or 'stat' method on
   the PS2, so the only way to discover if it exists is by trial and error.
   Now, unluckily, the logic in scummvm 'File::exists' is such, that it
   returns true iff (a) the file exist and (b) it's not a dir.

    FilesystemNode file(filename);
    if (file.exists())
        return !file.isDirectory();   <--- see ?

So knowing that the file exists is not enough, we have to rule out it's
not a dir. This is why I was using dopen and losing FD (which then was
causing the new engines to fail) when trying to open non-dir entries.

NOTE: The Filenodes were created with a _isDirectory true by default
      (without 'verify' before I implemented that), so the above was
      always failing.

A smart idea could be to "cache" the children of the higher nodes, and
to check against that if they exist and their nature (stat). Now, if we
have to do this every time we want to know if a file exists it's an overkill.
If we have to keep those caches (imagine the amount of nodes for somebody
that has all the ScummVM games on a PS2 HD), it's going to be a waste of
memory (and a very long cold startup). So maybe it wouldn't be so smart...

I hope this spread some light. Looking forward to your ideas.

Ciao,
 -max





More information about the Scummvm-devel mailing list