mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 12:49:20 +02:00
wrong file committed
This commit is contained in:
parent
f9f869fb37
commit
569dcecbb9
@ -17,221 +17,136 @@
|
|||||||
|
|
||||||
Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
|
Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
|
||||||
|
|
||||||
Var LinuxFlags : longint;
|
Begin
|
||||||
|
//!! Needs implementing
|
||||||
BEGIN
|
|
||||||
LinuxFlags:=0;
|
|
||||||
Case (Mode and 3) of
|
|
||||||
0 : LinuxFlags:=LinuxFlags or Open_RdOnly;
|
|
||||||
1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
|
|
||||||
2 : LinuxFlags:=LinuxFlags or Open_RdWr;
|
|
||||||
end;
|
|
||||||
FileOpen:=fdOpen (FileName,LinuxFlags);
|
|
||||||
//!! We need to set locking based on Mode !!
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileCreate (Const FileName : String) : Longint;
|
Function FileCreate (Const FileName : String) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileCreate:=FileOpen (FileName,Open_RdWr or Open_Creat);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
|
Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileRead:=fdRead (Handle,Buffer,Count);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileWrite (Handle : Longint; Var Buffer; Count : Longint) : Longint;
|
Function FileWrite (Handle : Longint; Var Buffer; Count : Longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileWrite:=fdWrite (Handle,Buffer,Count);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSeek (Handle,Offset,Origin : Longint) : Longint;
|
Function FileSeek (Handle,Offset,Origin : Longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileSeek:=fdSeek (Handle,Offset,Origin);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure FileClose (Handle : Longint);
|
Procedure FileClose (Handle : Longint);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
fdclose(Handle);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileAge (Const FileName : String): Longint;
|
Function FileAge (Const FileName : String): Longint;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If not fstat (FileName,Info) then
|
//!! Needs implementing
|
||||||
exit(-1)
|
|
||||||
else
|
|
||||||
Exit (Info.mtime);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileExists (Const FileName : String) : Boolean;
|
Function FileExists (Const FileName : String) : Boolean;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileExists:=fstat(filename,Info);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function LinuxToWinAttr (FN : Char; Const Info : Stat) : Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
Result:=0;
|
|
||||||
If FN='.' then
|
|
||||||
Result:=Result or faHidden;
|
|
||||||
If (Info.Mode and STAT_IFDIR)=STAT_IFDIR then
|
|
||||||
Result:=Result or faDirectory;
|
|
||||||
If (Info.Mode and STAT_IWUSR)=0 Then
|
|
||||||
Result:=Result or faReadOnly;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{
|
|
||||||
GlobToSearch takes a glob entry, stats the file.
|
|
||||||
The glob entry is removed.
|
|
||||||
If FileAttributes match, the entry is reused
|
|
||||||
}
|
|
||||||
|
|
||||||
Function GlobToTSearchRec (Info : TSearchRec) : Boolean;
|
|
||||||
|
|
||||||
Var SInfo : Stat;
|
|
||||||
p : Pglob;
|
|
||||||
TAttr : Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
P:=pglob(Info.FindHandle);
|
|
||||||
Result:=Fstat(p^.name,SInfo);
|
|
||||||
Info.FindHandle:=Longint(P^.Next);
|
|
||||||
P^.Next:=Nil;
|
|
||||||
GlobFree(P);
|
|
||||||
If Result then
|
|
||||||
begin
|
|
||||||
Info.Attr:=LinuxToWinAttr(p^.name[0],SInfo);
|
|
||||||
Result:=(Info.ExcludeAttr and TAttr)<>0 ;
|
|
||||||
If Result Then
|
|
||||||
With Info do
|
|
||||||
begin
|
|
||||||
Attr:=Info.Attr;
|
|
||||||
Name:=strpas(p^.name);
|
|
||||||
Time:=Sinfo.mtime;
|
|
||||||
Size:=Sinfo.Size;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Function DoFind(Var Rslt : TSearchRec) : Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
If Rslt.FindHandle<>0 then
|
|
||||||
While (Rslt.FindHandle<>0) and GlobToTSearchRec(Rslt) do;
|
|
||||||
If Rslt.FindHandle=0 Then
|
|
||||||
Result:=-1
|
|
||||||
else
|
|
||||||
Result:=0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
|
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Rslt.ExcludeAttr:=Attr; //!! Not correct !!
|
//!! Needs implementing
|
||||||
Rslt.FindHandle:=Longint(Glob(Path));
|
|
||||||
Result:=DoFind (Rslt);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=DoFind (Rslt);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure FindClose (Var F : TSearchrec);
|
Procedure FindClose (Var F : TSearchrec);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
GlobFree (PGlob(F.FindHandle));
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileGetDate (Handle : Longint) : Longint;
|
Function FileGetDate (Handle : Longint) : Longint;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Not(FStat(Handle,Info)) then
|
//!! Needs implementing
|
||||||
Result:=-1
|
|
||||||
else
|
|
||||||
Result:=Info.Mtime;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSetDate (Handle,Age : Longint) : Longint;
|
Function FileSetDate (Handle,Age : Longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Impossible under Linux from FileHandle !!
|
//!! Needs implementing
|
||||||
FileSetDate:=-1;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileGetAttr (Const FileName : String) : Longint;
|
Function FileGetAttr (Const FileName : String) : Longint;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Not FStat (FileName,Info) then
|
//!! Needs implementing
|
||||||
Result:=-1
|
|
||||||
Else
|
|
||||||
Result:=LinuxToWinAttr(FileName[1],Info);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Still Needs doing
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function DeleteFile (Const FileName : String) : Boolean;
|
Function DeleteFile (Const FileName : String) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=UnLink (FileName);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function RenameFile (Const OldName, NewName : String) : Boolean;
|
Function RenameFile (Const OldName, NewName : String) : Boolean;
|
||||||
|
|
||||||
Var P1,P2 : String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
RenameFile:=Linux.Rename(OldNAme,NewName);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSearch (Const Name, DirList : String) : String;
|
Function FileSearch (Const Name, DirList : String) : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileSearch:=Linux.FSearch(Name,Dirlist);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 1998-10-11 12:21:01 michael
|
Revision 1.2 1998-10-12 08:02:56 michael
|
||||||
|
wrong file committed
|
||||||
|
|
||||||
|
Revision 1.1 1998/10/11 12:21:01 michael
|
||||||
Added file calls. Implemented for linux only
|
Added file calls. Implemented for linux only
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,221 +17,136 @@
|
|||||||
|
|
||||||
Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
|
Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
|
||||||
|
|
||||||
Var LinuxFlags : longint;
|
Begin
|
||||||
|
//!! Needs implementing
|
||||||
BEGIN
|
|
||||||
LinuxFlags:=0;
|
|
||||||
Case (Mode and 3) of
|
|
||||||
0 : LinuxFlags:=LinuxFlags or Open_RdOnly;
|
|
||||||
1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
|
|
||||||
2 : LinuxFlags:=LinuxFlags or Open_RdWr;
|
|
||||||
end;
|
|
||||||
FileOpen:=fdOpen (FileName,LinuxFlags);
|
|
||||||
//!! We need to set locking based on Mode !!
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileCreate (Const FileName : String) : Longint;
|
Function FileCreate (Const FileName : String) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileCreate:=FileOpen (FileName,Open_RdWr or Open_Creat);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
|
Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileRead:=fdRead (Handle,Buffer,Count);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileWrite (Handle : Longint; Var Buffer; Count : Longint) : Longint;
|
Function FileWrite (Handle : Longint; Var Buffer; Count : Longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileWrite:=fdWrite (Handle,Buffer,Count);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSeek (Handle,Offset,Origin : Longint) : Longint;
|
Function FileSeek (Handle,Offset,Origin : Longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileSeek:=fdSeek (Handle,Offset,Origin);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure FileClose (Handle : Longint);
|
Procedure FileClose (Handle : Longint);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
fdclose(Handle);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileAge (Const FileName : String): Longint;
|
Function FileAge (Const FileName : String): Longint;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If not fstat (FileName,Info) then
|
//!! Needs implementing
|
||||||
exit(-1)
|
|
||||||
else
|
|
||||||
Exit (Info.mtime);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileExists (Const FileName : String) : Boolean;
|
Function FileExists (Const FileName : String) : Boolean;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileExists:=fstat(filename,Info);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function LinuxToWinAttr (FN : Char; Const Info : Stat) : Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
Result:=0;
|
|
||||||
If FN='.' then
|
|
||||||
Result:=Result or faHidden;
|
|
||||||
If (Info.Mode and STAT_IFDIR)=STAT_IFDIR then
|
|
||||||
Result:=Result or faDirectory;
|
|
||||||
If (Info.Mode and STAT_IWUSR)=0 Then
|
|
||||||
Result:=Result or faReadOnly;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{
|
|
||||||
GlobToSearch takes a glob entry, stats the file.
|
|
||||||
The glob entry is removed.
|
|
||||||
If FileAttributes match, the entry is reused
|
|
||||||
}
|
|
||||||
|
|
||||||
Function GlobToTSearchRec (Info : TSearchRec) : Boolean;
|
|
||||||
|
|
||||||
Var SInfo : Stat;
|
|
||||||
p : Pglob;
|
|
||||||
TAttr : Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
P:=pglob(Info.FindHandle);
|
|
||||||
Result:=Fstat(p^.name,SInfo);
|
|
||||||
Info.FindHandle:=Longint(P^.Next);
|
|
||||||
P^.Next:=Nil;
|
|
||||||
GlobFree(P);
|
|
||||||
If Result then
|
|
||||||
begin
|
|
||||||
Info.Attr:=LinuxToWinAttr(p^.name[0],SInfo);
|
|
||||||
Result:=(Info.ExcludeAttr and TAttr)<>0 ;
|
|
||||||
If Result Then
|
|
||||||
With Info do
|
|
||||||
begin
|
|
||||||
Attr:=Info.Attr;
|
|
||||||
Name:=strpas(p^.name);
|
|
||||||
Time:=Sinfo.mtime;
|
|
||||||
Size:=Sinfo.Size;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Function DoFind(Var Rslt : TSearchRec) : Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
If Rslt.FindHandle<>0 then
|
|
||||||
While (Rslt.FindHandle<>0) and GlobToTSearchRec(Rslt) do;
|
|
||||||
If Rslt.FindHandle=0 Then
|
|
||||||
Result:=-1
|
|
||||||
else
|
|
||||||
Result:=0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
|
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Rslt.ExcludeAttr:=Attr; //!! Not correct !!
|
//!! Needs implementing
|
||||||
Rslt.FindHandle:=Longint(Glob(Path));
|
|
||||||
Result:=DoFind (Rslt);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=DoFind (Rslt);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure FindClose (Var F : TSearchrec);
|
Procedure FindClose (Var F : TSearchrec);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
GlobFree (PGlob(F.FindHandle));
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileGetDate (Handle : Longint) : Longint;
|
Function FileGetDate (Handle : Longint) : Longint;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Not(FStat(Handle,Info)) then
|
//!! Needs implementing
|
||||||
Result:=-1
|
|
||||||
else
|
|
||||||
Result:=Info.Mtime;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSetDate (Handle,Age : Longint) : Longint;
|
Function FileSetDate (Handle,Age : Longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Impossible under Linux from FileHandle !!
|
//!! Needs implementing
|
||||||
FileSetDate:=-1;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileGetAttr (Const FileName : String) : Longint;
|
Function FileGetAttr (Const FileName : String) : Longint;
|
||||||
|
|
||||||
Var Info : Stat;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Not FStat (FileName,Info) then
|
//!! Needs implementing
|
||||||
Result:=-1
|
|
||||||
Else
|
|
||||||
Result:=LinuxToWinAttr(FileName[1],Info);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Still Needs doing
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function DeleteFile (Const FileName : String) : Boolean;
|
Function DeleteFile (Const FileName : String) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=UnLink (FileName);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function RenameFile (Const OldName, NewName : String) : Boolean;
|
Function RenameFile (Const OldName, NewName : String) : Boolean;
|
||||||
|
|
||||||
Var P1,P2 : String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
RenameFile:=Linux.Rename(OldNAme,NewName);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSearch (Const Name, DirList : String) : String;
|
Function FileSearch (Const Name, DirList : String) : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FileSearch:=Linux.FSearch(Name,Dirlist);
|
//!! Needs implementing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 1998-10-11 12:21:01 michael
|
Revision 1.2 1998-10-12 08:02:16 michael
|
||||||
|
wrong file committed
|
||||||
|
|
||||||
|
Revision 1.1 1998/10/11 12:21:01 michael
|
||||||
Added file calls. Implemented for linux only
|
Added file calls. Implemented for linux only
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user