RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStrings.ExpandFileNameCase Function

Get fully qualified filename by performing case-insensitive filename search looking for a close match.

Pascal
function ExpandFileNameCase(const FileName: AnsiString; out MatchFound: TFilenameCaseMatch): AnsiString; overload;
C++
AnsiString ExpandFileNameCase(const AnsiString FileName, TFilenameCaseMatch MatchFound);

ExpandFileNameCase returns a fully qualified filename like ExpandFileName, but performs a case-insensitive filename search looking for a close match in the actual file system, differing only in uppercase versus lowercase of the letters. This is useful to convert user input into usable file names or to convert filename data created on a case-insensitive file system (such as Windows) to something usable on a case-sensitive file system (such as Linux). 

The MatchFound out parameter indicates what kind of match was found in the file system and what the function result is based upon (in order of increasing difficulty or complexity):

  • mkExactMatch: Case-sensitive match. Result is ExpandFileName(FileName).
  • mkSingleMatch: Exactly one file in the given directory path matches the given filename on a case-insensitive basis. Returns ExpandFileName(FileName as found in file system).
  • mkAmbiguous: More than one file in the given directory path matches the given filename case-insensitively. In many cases, this should be considered an error. Result is ExpandFileName(First matching filename found).
  • mkNone: File not found at all. Returns ExpandFileName(FileName).

Note: Since this function searches the file system, it may be much slower than ExpandFileName, particularly when the given filename is ambiguous or does not exist. Use ExpandFileNameCase only when you have a filename of dubious origin (such as from user input) and you want to make a best guess before failing.
 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!