mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-02 03:39:46 +02:00
* fix FileExists on *nix systems returning True for directories
git-svn-id: trunk@43111 -
This commit is contained in:
parent
3dbbb18649
commit
46dac1419e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user