* Handle -1 return if GetFileAttr call inside DirectoryExists

git-svn-id: trunk@18220 -
This commit is contained in:
pierre 2011-08-16 15:01:20 +00:00
parent 83b2948ec1
commit 04a2d0bc94

View File

@ -304,7 +304,7 @@ Function DirectoryExists (Const Directory : String) : Boolean;
Var
Dir : String;
drive : byte;
StoredIORes : longint;
FADir, StoredIORes : longint;
begin
Dir:=Directory;
if (length(dir)=2) and (dir[2]=':') and
@ -335,11 +335,14 @@ begin
{$endif}
if (Length (Dir) > 1) and
(Dir [Length (Dir)] in AllowDirectorySeparators) and
(* Do not remove '\' after ':' (root directory of a drive)
(* Do not remove '\' after ':' (root directory of a drive)
or in '\\' (invalid path, possibly broken UNC path). *)
not (Dir [Length (Dir) - 1] in (AllowDriveSeparators + AllowDirectorySeparators)) then
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;