Damn, it doesn't work !
For example in /Developer/Platforms/MacOSX.platform/ I have these entries
drwxrwxr-x 3 root admin 102 18 mai 2009 Developer
-rw-rw-r-- 1 root admin 984 24 sep 2009 Info.plist
-rw-rw-r-- 1 root admin 38149 24 sep 2009 MacOSX.icns
-rw-rw-r-- 1 root admin 485 24 sep 2009 ResourceRules.plist
-rw-rw-r-- 1 root admin 402 24 sep 2009 version.plist
Developer is NOT a symbolic link but my code see it as a symbolic link.
Here is my code. What is wrong ?
Procedure ListAllFichiers(chemin: AnsiString; niveau : Tstrings);
Type
TUnixFindData = Record
NamePos : LongInt; {to track which search this is}
DirPtr : Pointer; {directory pointer for reading directory}
SearchSpec : String;
SearchType : Byte; {0=normal, 1=open will close, 2=only 1 file}
SearchAttr : Byte; {attribute we are searching for}
End;
PUnixFindData = ^TUnixFindData;
Var S:TSearchRec;
vc_ext: Ansistring;
F: TextFile;
vi_i, vi_numdir, vi_numfile: Integer;
vl_next, vl_ext: boolean;
I: Integer;
UnixFindData : PUnixFindData;
Begin
vi_numdir := 0;
vi_numfile := 0;
Chemin:=IncludeTrailingPathDelimiter(chemin);
If FindFirst(Chemin+'*',faAnyFile,S) = 0 Then Begin
Repeat
UnixFindData:=PUnixFindData(S.FindHandle);
// Don't scan . and .. !
If (S.Name<>'.')And(s.Name<>'..') then Begin
// Folder ? => recursive call
If (S.Attr And faDirectory)<>0 Then begin
// Ignore symbolic links
If ((((UnixFindData^.searchattr)) and faSymlink) <> 0) Then begin
trace(S.name); // write entry in a debug log file
end
else begin // scan it
inc(vi_numdir);
niveau[niveau.count - 1] := IntToStr(vi_numdir);
list(chemin[1], niveau,'R,' + S.Name); // Write entry in a file
niveau.Append('1');
ListAllFichiers(Chemin+S.Name, niveau);
niveau.Delete(niveau.count - 1);
end;
end
// It is a file
Else begin
list(chemin[1], niveau,'F,' + S.Name); // Write entry in a file
end;
end;
// Recherche du suivant
Until FindNext(S)<>0;
FindClose(S);
End;
End;