mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 21:19:31 +02: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);
|
||||
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}
|
||||
Begin
|
||||
FpAccess:=FpAccess(pchar(pathname),amode);
|
||||
|
@ -37,6 +37,8 @@ Function FpRmdir (path : AnsiString): cInt; inline;
|
||||
Function FpRename (old : AnsiString;newpath: AnsiString): cInt; inline;
|
||||
Function FpStat (path: AnsiString; var buf : stat): cInt; inline;
|
||||
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 FpWaitPid (pid : TPid; Var Status : cInt; Options : cint) : TPid;
|
||||
|
||||
|
@ -294,6 +294,10 @@ end;
|
||||
|
||||
Function LinuxToWinAttr (FN : Pchar; Const Info : Stat) : Longint;
|
||||
|
||||
Var
|
||||
FNL : String;
|
||||
LinkInfo : Stat;
|
||||
|
||||
begin
|
||||
Result:=faArchive;
|
||||
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
|
||||
Result:=Result or faSysFile;
|
||||
If fpS_ISLNK(Info.st_mode) Then
|
||||
begin
|
||||
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;
|
||||
|
||||
|
||||
@ -424,10 +434,15 @@ Function FindGetFileInfo(const s:string;var f:TSearchRec):boolean;
|
||||
var
|
||||
st : baseunix.stat;
|
||||
WinAttr : longint;
|
||||
|
||||
begin
|
||||
FindGetFileInfo:=false;
|
||||
if not fpstat(pointer(s),st)>=0 then
|
||||
exit;
|
||||
If Assigned(F.FindHandle) and ((((PUnixFindData(f.FindHandle)^.searchattr)) and faSymlink) > 0) then
|
||||
FindGetFileInfo:=(fplstat(pointer(s),st)=0)
|
||||
else
|
||||
FindGetFileInfo:=(fpstat(pointer(s),st)=0);
|
||||
If not FindGetFileInfo then
|
||||
exit;
|
||||
WinAttr:=LinuxToWinAttr(PChar(pointer(s)),st);
|
||||
If (f.FindHandle = nil) or ((WinAttr and Not(PUnixFindData(f.FindHandle)^.searchattr))=0) Then
|
||||
Begin
|
||||
@ -445,12 +460,10 @@ end;
|
||||
|
||||
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
|
||||
DirName : String;
|
||||
i,
|
||||
ArrayPos : Longint;
|
||||
FName,
|
||||
SName : string;
|
||||
Found,
|
||||
@ -501,7 +514,7 @@ End;
|
||||
|
||||
Function FindFirst (Const Path : String; Attr : Longint; out Rslt : TSearchRec) : Longint;
|
||||
{
|
||||
opens dir and calls FindWorkProc
|
||||
opens dir and calls FindNext if needed.
|
||||
}
|
||||
var
|
||||
UnixFindData : PUnixFindData;
|
||||
|
Loading…
Reference in New Issue
Block a user