* directoryexists added

This commit is contained in:
peter 2003-03-28 19:06:59 +00:00
parent cac1820c4c
commit 1714855f8e
4 changed files with 66 additions and 9 deletions

View File

@ -252,12 +252,33 @@ end;
Function FileExists (Const FileName : String) : Boolean;
var Handle: longint;
Var
Sr : Searchrec;
begin
//!! This can be done quicker, need to find out how
Result := (OpenFile(FileName, Handle, ofRead, faOpen) = 0);
if Handle <> 0 then
FileClose(Handle);
DOS.FindFirst(Path,$3f,sr);
if DosError = 0 then
begin
{ No volumeid,directory }
Result:=(sr.attr and $18)=0;
Dos.FindClose(sr);
end
else
Result:=false;
end;
Function DirectoryExists (Const DirName : String) : Boolean;
Var
Sr : Searchrec;
begin
DOS.FindFirst(Path,$3f,sr);
if DosError = 0 then
begin
Result:=(sr.attr and $10)=$10;
Dos.FindClose(sr);
end
else
Result:=false;
end;
@ -730,7 +751,10 @@ Finalization
end.
{
$Log$
Revision 1.11 2003-01-03 20:41:04 peter
Revision 1.12 2003-03-28 19:06:59 peter
* directoryexists added
Revision 1.11 2003/01/03 20:41:04 peter
* FileCreate(string,mode) overload added
Revision 1.10 2002/09/07 16:01:19 peter

View File

@ -70,6 +70,7 @@ Procedure FileClose (Handle : Longint);
Function FileTruncate (Handle,Size: Longint) : boolean;
Function FileAge (Const FileName : String): Longint;
Function FileExists (Const FileName : String) : Boolean;
Function DirectoryExists (Const DirName : String) : Boolean;
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
Function FindNext (Var Rslt : TSearchRec) : Longint;
Procedure FindClose (Var F : TSearchrec);
@ -84,7 +85,10 @@ Function FileSearch (Const Name, DirList : String) : String;
{
$Log$
Revision 1.7 2003-01-03 20:41:04 peter
Revision 1.8 2003-03-28 19:06:59 peter
* directoryexists added
Revision 1.7 2003/01/03 20:41:04 peter
* FileCreate(string,mode) overload added
Revision 1.6 2002/09/07 16:01:22 peter

View File

@ -142,6 +142,16 @@ begin
end;
Function DirectoryExists (Const DirName : String) : Boolean;
Var Info : Stat;
begin
DirectoryExists:=fstat(dirname,Info) and
((info.mode and STAT_IFMT)=STAT_IFDIR);
end;
Function LinuxToWinAttr (FN : Pchar; Const Info : Stat) : Longint;
begin
@ -481,7 +491,10 @@ end.
{
$Log$
Revision 1.14 2003-01-03 20:41:04 peter
Revision 1.15 2003-03-28 19:06:59 peter
* directoryexists added
Revision 1.14 2003/01/03 20:41:04 peter
* FileCreate(string,mode) overload added
Revision 1.13 2002/09/07 16:01:28 peter

View File

@ -186,6 +186,19 @@ begin
end;
Function DirectoryExists (Const DirName : String) : Boolean;
var
Handle: THandle;
FindData: TWin32FindData;
begin
Handle := FindFirstFile(Pchar(FileName), @FindData);
Result:=(Handle <> INVALID_HANDLE_VALUE) and
((FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY);
If Result then
Windows.FindClose(Handle);
end;
Function FindMatch(var f: TSearchRec) : Longint;
begin
{ Find file with correct attribute }
@ -670,7 +683,10 @@ Finalization
end.
{
$Log$
Revision 1.19 2003-01-03 20:41:04 peter
Revision 1.20 2003-03-28 19:06:59 peter
* directoryexists added
Revision 1.19 2003/01/03 20:41:04 peter
* FileCreate(string,mode) overload added
Revision 1.18 2003/01/01 20:56:57 florian