mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 10:29:08 +02:00
* Handle -1 return if GetFileAttr call inside DirectoryExists
git-svn-id: trunk@18220 -
This commit is contained in:
parent
83b2948ec1
commit
04a2d0bc94
@ -304,7 +304,7 @@ Function DirectoryExists (Const Directory : String) : Boolean;
|
|||||||
Var
|
Var
|
||||||
Dir : String;
|
Dir : String;
|
||||||
drive : byte;
|
drive : byte;
|
||||||
StoredIORes : longint;
|
FADir, StoredIORes : longint;
|
||||||
begin
|
begin
|
||||||
Dir:=Directory;
|
Dir:=Directory;
|
||||||
if (length(dir)=2) and (dir[2]=':') and
|
if (length(dir)=2) and (dir[2]=':') and
|
||||||
@ -339,7 +339,10 @@ begin
|
|||||||
or in '\\' (invalid path, possibly broken UNC path). *)
|
or in '\\' (invalid path, possibly broken UNC path). *)
|
||||||
not (Dir [Length (Dir) - 1] in (AllowDriveSeparators + AllowDirectorySeparators)) then
|
not (Dir [Length (Dir) - 1] in (AllowDriveSeparators + AllowDirectorySeparators)) then
|
||||||
dir:=copy(dir,1,length(dir)-1);
|
dir:=copy(dir,1,length(dir)-1);
|
||||||
Result := FileGetAttr (Dir) and faDirectory = faDirectory;
|
(* FileGetAttr returns -1 on error *)
|
||||||
|
FADir := FileGetAttr (Dir);
|
||||||
|
Result := (FADir <> -1) and
|
||||||
|
((FADir and faDirectory) = faDirectory);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user