[Scummvm-devel] Case agnostic handling for directories (and files)

Max Horn max at quendi.de
Tue Sep 22 12:05:06 CEST 2009


Hi folks,

currently, engines like e.g. AGOS do things like this:
   File::addDefaultDirectory(_gameDataDir.getChild("execute"));
   File::addDefaultDirectory(_gameDataDir.getChild("EXECUTE"));
in an attempt to cover how that subdir is named under various  
circumstances. This approach is currently the only possible (without  
lots of annoying foot work), but has drawbacks: E.g. it fails if the  
dir is named "Execute" or uses any other capitalization.

Moreover, it seems wrong to add what is essentially the same dir  
multiple times. On OS X, the default file system preserves case but  
ignores it for purposes of file access. Hence all of "execute",  
"EXECUTE" and "Execute" would access the same directory -- if one  
exists, then the other three also "exist". So we might end up  
inserting data multiple times in our file cache.

A better way would be to loop over all children of _gameDataDir,  
compare the name of each to "execute", *ignoring case*. And add every  
match.

It's pretty easy to implement that, the main question(s) involve  
details, I feel:
* new  method of class Engine:
     void Engine::addGameDataSubdirToSeachMan(String caselessName);
    OR
     void Engine::addGameDataSubdirsToSeachMan(String pattern, bool  
ignoreCase);

* new generic method in SearchMan resp. SearchSet:
     void SearchSet::addSubdirsMatching(FSNode &dir, String  
caselessName);
     void SearchSet::addSubdirsMatching(FSNode &dir, String pattern,  
bool ignoreCase);

At the same time, one could wonder whether we should extend more  
Archive methods which match a name to have an "bool ignoreCase"  
parameter (defaulting to false).

In any case, once we implement one of the above (or some alternative  
solution, I am open to suggestions!) would allow us to get rid of  
File::addDefaultDirectory() for good (one can just use the SearchMan  
methods directly these days).


Cheers,
Max




More information about the Scummvm-devel mailing list