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

Max Horn max at quendi.de
Tue Sep 22 12:50:30 CEST 2009


Am 22.09.2009 um 12:39 schrieb Johannes Schickel:

> 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?

Not necessarily. My email was a bit garbled (happens if you copy&paste  
too much :-/ ). Think of it as saying the following, right after  
"involve details":
   "Potential ways to address this include the following new APIs (we  
could take one or both or none :)."

[...]


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

I have no particular example in mind. It was just natural given the  
name "addSubdirsMatching" ;), and given the fact that it's a trivial  
one line addition to turn the former into the latter. Also, I feel  
that this name is not so suitable if we go with the "single caseless  
string" variant... OTOH the function name should still indicate that  
multiple dirs might be added.

But again, I really have no strong feelings either way. We can go with  
the first variant and add the second one (possibly replacing the  
former one) if we need it later on. :)


So, do you want to add it? :)


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

Well, it was just a wild idea -- right now I have no specific usage  
cases in mind. But I thought that some Engine authors might shout  
"hear head, that's just what I need" ;). If that's not the case, let's  
shelf the idea for the time being.


Cheers,
Max




More information about the Scummvm-devel mailing list