I need to make a unix-compatible windows delphi procedure, which confirms whether the file name on the file system exists in exactly the same CaSe as required, for example. "John.txt" is, not "john.txt".
If I check "FileExists (" john.txt "), it is always true for the John.txt and JOHN.TXT windows.
How can I create a FileExistsCaseSensitive (myfile) function to confirm that the file is really what it should be.
DELPHI Sysutils.FileExists uses the following function to see if there is a file, how to change it, to double-check the file name in the file system, has lowercase letters and exists:
function FileAge(const FileName: string): Integer;
var
Handle: THandle;
FindData: TWin32FindData;
LocalFileTime: TFileTime;
begin
Handle := FindFirstFile(PChar(FileName), FindData);
if Handle <> INVALID_HANDLE_VALUE then
begin
Windows.FindClose(Handle);
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin
FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
if FileTimeToDosDateTime(LocalFileTime, LongRec(Result).Hi,
LongRec(Result).Lo) then Exit;
end;
end;
Result := -1;
end;