* fix FileExists on *nix systems returning True for directories

git-svn-id: trunk@43111 -
This commit is contained in:
svenbarth 2019-10-03 12:07:25 +00:00
parent 3dbbb18649
commit 46dac1419e

View File

@ -617,12 +617,18 @@ end;
Function FileExists (Const FileName : RawByteString; FollowLink : Boolean) : Boolean;
var
Info : Stat;
SystemFileName: RawByteString;
begin
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
// Don't use stat. It fails on files >2 GB.
// Access obeys the same access rules, so the result should be the same.
FileExists:=fpAccess(pointer(SystemFileName),F_OK)=0;
{ we need to ensure however that we aren't dealing with a directory }
if FileExists then begin
if (fpstat(pointer(SystemFileName),Info)>=0) and fpS_ISDIR(Info.st_mode) then
FileExists:=False;
end;
end;
Function DirectoryExists (Const Directory : RawByteString; FollowLink : Boolean) : Boolean;