[Scummvm-devel] New File(Manager) API

Max Horn max at quendi.de
Sun Apr 11 13:36:01 CEST 2004


Am 11.04.2004 um 14:59 schrieb James 'Ender' Brown:

> Looks good!
>
> Just to pop an idea I've been thinking of lately into the discussion...
> the ability to cache directory contents in a struct ala:
>
>  char *name;	 // tolower()'ed name
>  char *realName; // Original name
>  byte fsType;    // dir, file, whatever

This is not directory content... or did you mean you wanted to "cache" 
a list of all files in a given directory, together with information 
about those files (like the file name, and the file type) ? That's 
already there, in the form of the FilePath::listFiles() method. E.g. 
consider this code example, which you can use to perform an action for 
all files directories below a given path:

void recurseDirectory(FilePath path, FunctionPtr func) {
   assert(path.exists());
   if (path.isDirectory()) {
     PathList files = path.listFiles();
     for (PathList::iterator iter = files.begin(); iter != files.end(); 
++iter) {
       recurseDirectory(*iter, func);
     }
   } else {
     func(path);
   }
}

Regardin the "lower case file name", I don't think that should be part 
of the FilePath class directly. How would you handle conflicts if you 
are working on a case sensitive file system and both MONKEY.000 and 
monkey.000 exist (admittedly, a nasty scenario anyway, but one higher 
level code should deal with; if we ignore case in the lower level, we 
make it impossible to ever write code which handles it 'nicely').

Of course, we still want a way to open a given file regardless of case. 
This is essentially what I try to cover by the tryOpenFile() helper 
function, as well as with search paths.

But maybe I am misunderstanding what you are asking for -- in which 
case, please explain what you exactly want to achieve :-)


> This would allow the removal of a lot of hacks that currently exist to
> deal with case on case-sensitive systems.
>
> Would it be possible to implement this type of functionality into
> FileNode? At least in the POSIX backend, which is probably the only one
> that is actually case-sensitive.

Everything is possible. However, I am not quite I understand what you 
are asking for...


Cheers,

Max





More information about the Scummvm-devel mailing list