On a case-insensitive file system, such as NTFS or HFS+, given the name of a file, what is the most efficient way to determine the case-preserved version of the file name?
Consider on HFS+ (Mac OS X):
> perl -E 'say "yes" if -e "/TMP"'
yes
It says it exists, of course, but I have no idea how its case is preserved. What's the most efficient way to determine the actual case?
What I've tried so far:
glob
with character classes: It doesn't work on Windows:> perl -E "say for glob "C:\\Perl" C:\Perl > perl -E "say for glob "C:\\[Pp][Ee][Rr][Ll]"
Note the lack of output from that last command. :-(
opendir
/readdir
: Works, but seems rather inefficient to read an entire directory:> perl -E "opendir my $dh, 'C:\\'; say for grep { lc $_ eq 'perl' } readdir $dh; close $dh" Perl
Is it crazy to think that there ought to be some core operating system instructions or something to get at this information more efficiently?