[fpc-pascal] Case insensitive FindFirst and friends

Brad Campbell brad at wasp.net.au
Mon May 18 11:58:17 CEST 2009


Jonas Maebe wrote:
> 
> On 18 May 2009, at 08:18, Brad Campbell wrote:
> 
>> In this application I'm populating a stringlist with a list of files 
>> in a directory with a specific extension, but of course I've just 
>> realised that the case of that extension is tripping me up. Is there a 
>> better way to achieve what I want in a cross platform manner while 
>> retaining the case insensitivity?
> 
> The only way is reading the entire directory in memory, and then 
> performing your own case-insensitive search on that. The compiler does 
> the same (see compiler/cfileutl.pas -- or do not look at it, depending 
> on the license of your program, since that code is GPL). The big 
> downside of this approach is that it can introduce very noticeable 
> delays in your program's operation when working on networked file 
> systems (especially if there are lots of files in a directory).

Yes, I've done it this way previously (and even in another component of this software). I just 
wondered if there was a better way. OSX can be a little slow over the network sometimes, but it's 
not proved a big issue.

> I think the only real solution is accept that different OSes do not 
> behave exactly the same, as this will by no means be the only difference 
> they'll encounter. You will not be able to "fix" all of them, unless you 
> start really emulating one OS on top of the others (in which case you'll 
> alienate the "native" users of that platform). And almost every single 
> one of those changes will make your program slower, harder to maintain 
> and harder to port.

Unfortunately this software is being used by people who tend to transport their data from platform 
to platform, and they expect the software to be bug for bug compatible across all the platforms. 
I'll just have a play with making the case insensitive search as efficient as I can and leave it at 
that. I have different key maps across the platforms, serial handling is also different, but things 
like file names are a sticky one. People expect to share one directory on a server and access it 
from the three platforms and get the same results.

Thanks for the advice :)

Regards,
-- 
Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them
fish.



More information about the fpc-pascal mailing list