Przeglądaj źródła

* also return fasymbolic if dir is found.
* update getattr to also return fasymbolic
Patch by Dimitri B. Mantis #16817

git-svn-id: trunk@18043 -

marco 14 lat temu
rodzic
commit
7eeb4ab539
1 zmienionych plików z 12 dodań i 8 usunięć
  1. 12 8
      rtl/unix/sysutils.pp

+ 12 - 8
rtl/unix/sysutils.pp

@@ -561,14 +561,15 @@ Function LinuxToWinAttr (const FN : Ansistring; Const Info : Stat) : Longint;
 
 Var
   LinkInfo : Stat;
-
+  nm : AnsiString;
 begin
   Result:=faArchive;
   If fpS_ISDIR(Info.st_mode) then
     Result:=Result or faDirectory;
-  If (Length(FN)>=2) and
-     (FN[1]='.') and
-     (FN[2]<>'.')  then
+  nm:=ExtractFileName(FN);
+  If (Length(nm)>=2) and
+     (nm[1]='.') and
+     (nm[2]<>'.')  then
     Result:=Result or faHidden;
   If (Info.st_Mode and S_IWUSR)=0 Then
      Result:=Result or faReadOnly;
@@ -706,7 +707,7 @@ begin
     FindGetFileInfo:=(fpstat(pointer(s),st)=0);
   If not FindGetFileInfo then
     exit;
-  WinAttr:=LinuxToWinAttr(ExtractFileName(s),st);
+  WinAttr:=LinuxToWinAttr(s,st);
   If ((WinAttr and Not(PUnixFindData(f.FindHandle)^.searchattr))=0) Then
    Begin
      f.Name:=ExtractFileName(s);
@@ -842,12 +843,15 @@ end;
 Function FileGetAttr (Const FileName : String) : Longint;
 
 Var Info : Stat;
-
+  res : Integer;
 begin
-  If  FpStat (pointer(FileName),Info)<0 then
+  res:=FpLStat (pointer(FileName),Info);
+  if res<0 then
+    res:=FpStat (pointer(FileName),Info);
+  if res<0 then
     Result:=-1
   Else
-    Result:=LinuxToWinAttr(Pchar(ExtractFileName(FileName)),Info);
+    Result:=LinuxToWinAttr(Pchar(FileName),Info);
 end;