I have the following need, which I'm afraid is not very common, because I've searched online for a solution, but I haven't found anything, not only the solution (it happens that I can't find it), but even someone else who has asked the usual question.
So: Windows is not case sensitive. Luckily, when I use Linux, I go crazy for capital letters, but this has an aesthetic effect that disturbs me (I know it's not a big problem).
If a file is called Abcdefhi.Jkl and I type abcDEFHI.jkL instead, the program is fine anyway, it recognises it and continues processing.
The aesthetics is that it remains "badly" written throughout the program. When the program has to return the filename, it does so as it was set, not as it actually is.
So I wrote a function, which I called TrueName, which converts the set name to the real name, preserving the case. Unfortunately, ExpandFileName doesn't do this as I had hoped; if you have spelt it "badly", it doesn't fix things.
TrueName works like this: instead of checking the existence of the file with FileExists, as I usually do, I search for the set name with FindFirst, then I read the variable <dot>Name of the TSearchRec record, which corresponds to the real name with the correct capitalisation, obviously FindFirst<>0 corresponds to False of FileExists.
Is everything solved? Far from it.
Firstly, there may be a more efficient algorithm than mine, if so I would be delighted. Secondly, the FindFirst trick only applies to the name, the rest of the path, i.e. the names of the various parent directories, still retain the case set by the keyboard, even if they differ in case from the original.
So I should apply the FindFirst trick to each directory in the path. One at a time. So if my algorithm was not efficient, the inefficiency would be multiplied by the depth of the path.
Maybe, I wondered, there is a function already written that returns the true full name of the path.
Do you know of any? Thanks for your attention.
Sorry for the length, but it doesn't seem like a very serious problem to me, so I had to explain it well to avoid misunderstandings.