Recent

Author Topic: Recursive File Searching  (Read 6684 times)

tbonejo

  • Jr. Member
  • **
  • Posts: 66
Recursive File Searching
« on: September 01, 2008, 05:25:30 am »
Im trying to do some file searching in OSX and have converted to an extent a delphi method but cannot seem to get this to drill down into other directories.

Here is my code:

Code: [Select]
procedure TForm1.FileSearch(const PathName, FileName : string; const InDir : boolean);
var Rec  : TSearchRec;
    Path : string;
begin
Path := IncludeTrailingBackslash(PathName);
if FindFirst(Path + FileName, faAnyFile - faDirectory, Rec) = 0 then
 try
   repeat
     Label2.Caption:= Path + Rec.Name;
     Label2.refresh;
     ListBox1.Items.Append(Path + Rec.Name) ;
     ListBox1.MakeCurrentVisible ;

   until FindNext(Rec) <> 0;
 finally
   FindClose(Rec);
 end;

If not InDir then Exit;

if FindFirst(Path + '*.*', faDirectory, Rec) = 0 then
 try
   repeat
    if ((Rec.Attr and faDirectory) <> 0)  and (Rec.Name<>'.') and (Rec.Name<>'..') then
     FileSearch(Path + Rec.Name, FileName, True);
   until FindNext(Rec) <> 0;
 finally
   FindClose(Rec);
 end;
end; //procedure FileSearch                              


Any ideas on what I am doing wrong?

Thanks.

Tombo

  • New Member
  • *
  • Posts: 21
RE: Recursive File Searching
« Reply #1 on: September 01, 2008, 10:32:47 am »
Replace '*.*' with '*' or constant AllFilesMask.
Mask '*.*' matches  includes directories only on win platform.

tbonejo

  • Jr. Member
  • **
  • Posts: 66
RE: Recursive File Searching
« Reply #2 on: September 01, 2008, 03:39:04 pm »
Thanks that did the trick.

Is there anything special to access resource forks and stuff within files?

Thanks.

 

TinyPortal © 2005-2018