mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-01 20:32:02 +02:00
* patch from Luiz Américo:
1 - Return false when the argument is a directory (like Delphi) 2 - Return false when passing '*' as argument (like Delphi) 3 - Its faster git-svn-id: trunk@1404 -
This commit is contained in:
parent
f67ffaa7c8
commit
396b5524ee
@ -247,13 +247,13 @@ end;
|
|||||||
|
|
||||||
Function FileExists (Const FileName : String) : Boolean;
|
Function FileExists (Const FileName : String) : Boolean;
|
||||||
var
|
var
|
||||||
Handle: THandle;
|
Attr:Dword;
|
||||||
FindData: TWin32FindData;
|
|
||||||
begin
|
begin
|
||||||
Handle := FindFirstFile(Pchar(FileName), FindData);
|
Attr:=GetFileAttributes(PChar(FileName));
|
||||||
Result:=Handle <> INVALID_HANDLE_VALUE;
|
if Attr <> $ffffffff then
|
||||||
If Result then
|
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0
|
||||||
Windows.FindClose(Handle);
|
else
|
||||||
|
Result:=False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -354,16 +354,16 @@ end;
|
|||||||
|
|
||||||
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
||||||
begin
|
begin
|
||||||
if not SetFileAttributes(PChar(FileName), Attr) then
|
if SetFileAttributes(PChar(FileName), Attr) then
|
||||||
Result := GetLastError
|
Result:=0
|
||||||
else
|
else
|
||||||
Result:=0;
|
Result := GetLastError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function DeleteFile (Const FileName : String) : Boolean;
|
Function DeleteFile (Const FileName : String) : Boolean;
|
||||||
begin
|
begin
|
||||||
DeleteFile:=Windows.DeleteFile(Pchar(FileName));
|
Result:=Windows.DeleteFile(Pchar(FileName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -468,28 +468,19 @@ end;
|
|||||||
|
|
||||||
Function SetCurrentDir (Const NewDir : String) : Boolean;
|
Function SetCurrentDir (Const NewDir : String) : Boolean;
|
||||||
begin
|
begin
|
||||||
{$I-}
|
Result:=SetCurrentDirectory(PChar(NewDir));
|
||||||
ChDir(NewDir);
|
|
||||||
{$I+}
|
|
||||||
result := (IOResult = 0);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function CreateDir (Const NewDir : String) : Boolean;
|
Function CreateDir (Const NewDir : String) : Boolean;
|
||||||
begin
|
begin
|
||||||
{$I-}
|
Result:=CreateDirectory(PChar(NewDir),nil);
|
||||||
MkDir(NewDir);
|
|
||||||
{$I+}
|
|
||||||
result := (IOResult = 0);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function RemoveDir (Const Dir : String) : Boolean;
|
Function RemoveDir (Const Dir : String) : Boolean;
|
||||||
begin
|
begin
|
||||||
{$I-}
|
Result:=RemoveDirectory(PChar(Dir));
|
||||||
RmDir(Dir);
|
|
||||||
{$I+}
|
|
||||||
result := (IOResult = 0);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user