From 396b5524eefa0a78eacf73ebb9fa9589c41f3cc7 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 16 Oct 2005 09:17:41 +0000 Subject: [PATCH] =?UTF-8?q?*=20patch=20from=20Luiz=20Am=C3=A9rico:=20=20?= =?UTF-8?q?=201=20-=20Return=20false=20when=20the=20argument=20is=20a=20di?= =?UTF-8?q?rectory=20(like=20Delphi)=20=20=202=20-=20Return=20false=20when?= =?UTF-8?q?=20passing=20'*'=20as=20argument=20(like=20Delphi)=20=20=203=20?= =?UTF-8?q?-=20Its=20faster?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: trunk@1404 - --- rtl/win32/sysutils.pp | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/rtl/win32/sysutils.pp b/rtl/win32/sysutils.pp index 5fd457c2da..4233b8bd97 100644 --- a/rtl/win32/sysutils.pp +++ b/rtl/win32/sysutils.pp @@ -247,13 +247,13 @@ end; Function FileExists (Const FileName : String) : Boolean; var - Handle: THandle; - FindData: TWin32FindData; + Attr:Dword; begin - Handle := FindFirstFile(Pchar(FileName), FindData); - Result:=Handle <> INVALID_HANDLE_VALUE; - If Result then - Windows.FindClose(Handle); + Attr:=GetFileAttributes(PChar(FileName)); + if Attr <> $ffffffff then + Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0 + else + Result:=False; end; @@ -354,16 +354,16 @@ end; Function FileSetAttr (Const Filename : String; Attr: longint) : Longint; begin - if not SetFileAttributes(PChar(FileName), Attr) then - Result := GetLastError + if SetFileAttributes(PChar(FileName), Attr) then + Result:=0 else - Result:=0; + Result := GetLastError; end; Function DeleteFile (Const FileName : String) : Boolean; begin - DeleteFile:=Windows.DeleteFile(Pchar(FileName)); + Result:=Windows.DeleteFile(Pchar(FileName)); end; @@ -468,28 +468,19 @@ end; Function SetCurrentDir (Const NewDir : String) : Boolean; begin - {$I-} - ChDir(NewDir); - {$I+} - result := (IOResult = 0); + Result:=SetCurrentDirectory(PChar(NewDir)); end; Function CreateDir (Const NewDir : String) : Boolean; begin - {$I-} - MkDir(NewDir); - {$I+} - result := (IOResult = 0); + Result:=CreateDirectory(PChar(NewDir),nil); end; Function RemoveDir (Const Dir : String) : Boolean; begin - {$I-} - RmDir(Dir); - {$I+} - result := (IOResult = 0); + Result:=RemoveDirectory(PChar(Dir)); end;