mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-09 19:39:51 +01:00
* Added overloaded call for fplstat which has var argument (as for stat)
* Implemented support for faSymlink, as per 9915 git-svn-id: trunk@11681 -
This commit is contained in:
parent
ca4fa01f8f
commit
7a058a9bf2
@ -110,6 +110,18 @@ begin
|
|||||||
FpStat:=FpStat(pchar(path),buf);
|
FpStat:=FpStat(pchar(path),buf);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Function fpLstat (path:pchar;var Info:stat):cint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
fpLstat:=fplstat(path,@info);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function fpLstat (Filename: ansistring;var Info:stat):cint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
fpLstat:=fplstat(filename,@info);
|
||||||
|
end;
|
||||||
|
|
||||||
Function FpAccess (pathname : AnsiString; aMode : cInt): cInt; {$ifdef VER2_0}inline;{$endif}
|
Function FpAccess (pathname : AnsiString; aMode : cInt): cInt; {$ifdef VER2_0}inline;{$endif}
|
||||||
Begin
|
Begin
|
||||||
FpAccess:=FpAccess(pchar(pathname),amode);
|
FpAccess:=FpAccess(pchar(pathname),amode);
|
||||||
|
|||||||
@ -37,6 +37,8 @@ Function FpRmdir (path : AnsiString): cInt; inline;
|
|||||||
Function FpRename (old : AnsiString;newpath: AnsiString): cInt; inline;
|
Function FpRename (old : AnsiString;newpath: AnsiString): cInt; inline;
|
||||||
Function FpStat (path: AnsiString; var buf : stat): cInt; inline;
|
Function FpStat (path: AnsiString; var buf : stat): cInt; inline;
|
||||||
Function FpStat (path: String; var buf : stat): cInt;
|
Function FpStat (path: String; var buf : stat): cInt;
|
||||||
|
Function fpLstat (path:pchar;var Info:stat):cint;
|
||||||
|
Function fpLstat (Filename: ansistring;var Info:stat):cint;
|
||||||
Function FpAccess (pathname : AnsiString; aMode : cInt): cInt; inline;
|
Function FpAccess (pathname : AnsiString; aMode : cInt): cInt; inline;
|
||||||
function FpWaitPid (pid : TPid; Var Status : cInt; Options : cint) : TPid;
|
function FpWaitPid (pid : TPid; Var Status : cInt; Options : cint) : TPid;
|
||||||
|
|
||||||
|
|||||||
@ -294,6 +294,10 @@ end;
|
|||||||
|
|
||||||
Function LinuxToWinAttr (FN : Pchar; Const Info : Stat) : Longint;
|
Function LinuxToWinAttr (FN : Pchar; Const Info : Stat) : Longint;
|
||||||
|
|
||||||
|
Var
|
||||||
|
FNL : String;
|
||||||
|
LinkInfo : Stat;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=faArchive;
|
Result:=faArchive;
|
||||||
If fpS_ISDIR(Info.st_mode) then
|
If fpS_ISDIR(Info.st_mode) then
|
||||||
@ -305,7 +309,13 @@ begin
|
|||||||
If fpS_ISSOCK(Info.st_mode) or fpS_ISBLK(Info.st_mode) or fpS_ISCHR(Info.st_mode) or fpS_ISFIFO(Info.st_mode) Then
|
If fpS_ISSOCK(Info.st_mode) or fpS_ISBLK(Info.st_mode) or fpS_ISCHR(Info.st_mode) or fpS_ISFIFO(Info.st_mode) Then
|
||||||
Result:=Result or faSysFile;
|
Result:=Result or faSysFile;
|
||||||
If fpS_ISLNK(Info.st_mode) Then
|
If fpS_ISLNK(Info.st_mode) Then
|
||||||
|
begin
|
||||||
Result:=Result or faSymLink;
|
Result:=Result or faSymLink;
|
||||||
|
// Windows reports if the link points to a directory.
|
||||||
|
FNL:=StrPas(FN);
|
||||||
|
if (fpstat(FNL,LinkInfo)>=0) and fpS_ISDIR(LinkInfo.st_mode) then
|
||||||
|
Result := Result or faDirectory;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -424,10 +434,15 @@ Function FindGetFileInfo(const s:string;var f:TSearchRec):boolean;
|
|||||||
var
|
var
|
||||||
st : baseunix.stat;
|
st : baseunix.stat;
|
||||||
WinAttr : longint;
|
WinAttr : longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FindGetFileInfo:=false;
|
FindGetFileInfo:=false;
|
||||||
if not fpstat(pointer(s),st)>=0 then
|
If Assigned(F.FindHandle) and ((((PUnixFindData(f.FindHandle)^.searchattr)) and faSymlink) > 0) then
|
||||||
exit;
|
FindGetFileInfo:=(fplstat(pointer(s),st)=0)
|
||||||
|
else
|
||||||
|
FindGetFileInfo:=(fpstat(pointer(s),st)=0);
|
||||||
|
If not FindGetFileInfo then
|
||||||
|
exit;
|
||||||
WinAttr:=LinuxToWinAttr(PChar(pointer(s)),st);
|
WinAttr:=LinuxToWinAttr(PChar(pointer(s)),st);
|
||||||
If (f.FindHandle = nil) or ((WinAttr and Not(PUnixFindData(f.FindHandle)^.searchattr))=0) Then
|
If (f.FindHandle = nil) or ((WinAttr and Not(PUnixFindData(f.FindHandle)^.searchattr))=0) Then
|
||||||
Begin
|
Begin
|
||||||
@ -445,12 +460,10 @@ end;
|
|||||||
|
|
||||||
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
||||||
{
|
{
|
||||||
re-opens dir if not already in array and calls FindWorkProc
|
re-opens dir if not already in array and calls FindGetFileInfo
|
||||||
}
|
}
|
||||||
Var
|
Var
|
||||||
DirName : String;
|
DirName : String;
|
||||||
i,
|
|
||||||
ArrayPos : Longint;
|
|
||||||
FName,
|
FName,
|
||||||
SName : string;
|
SName : string;
|
||||||
Found,
|
Found,
|
||||||
@ -501,7 +514,7 @@ End;
|
|||||||
|
|
||||||
Function FindFirst (Const Path : String; Attr : Longint; out Rslt : TSearchRec) : Longint;
|
Function FindFirst (Const Path : String; Attr : Longint; out Rslt : TSearchRec) : Longint;
|
||||||
{
|
{
|
||||||
opens dir and calls FindWorkProc
|
opens dir and calls FindNext if needed.
|
||||||
}
|
}
|
||||||
var
|
var
|
||||||
UnixFindData : PUnixFindData;
|
UnixFindData : PUnixFindData;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user