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

Johannes Schickel lordhoto at scummvm.org
Tue Sep 22 12:39:58 CEST 2009


Max Horn wrote:
> 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);
>   

Do we really need these? I would actually rather only go with SearchMan 
additions itself, when it comes to that. After all it looks like they 
are only convenience wrappers and personally I fail to see the real 
connection of those methods with what our Engine object really tries to 
represent.

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

Looks fine to me. Actually I had something very similar in mind ;-). 
Short question though: is there any use case for the pattern match? It 
shouldn't be much overhead to implement it (especially since one could 
easily implement the method just taking the caselessName via the pattern 
one), but actually I fail to see where it is really useful.

> 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).
>   

We could do that for consistency aye. Currently I think most (all?) of 
our Archive implementations do have case insensitive comparison in their 
implementations though, so either we set the default to true, which 
looks sane for most use cases IMHO, or we need to change all code to 
pass "true". Of course in all cases (that is keeping it like it is 
currently, addition with default to "false" or addition with default to 
"true") it should be documented clearly :-).

> 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).
>   

I'm all for getting rid of that method of File :-).

// Johannes




More information about the Scummvm-devel mailing list