FPC: recursive "FileFind", corrected... 
Author Message
 FPC: recursive "FileFind", corrected...

Just added my "DoRest" in the "FindDirs" if anyone wonder why I never
called it.

procedure FindDirs(ADir: string);

  procedure DoRest(_ADir: string);
  var
    sr: TSearchRec;
    e: LongInt;
    Strs: TStrings;
    i: integer;
  begin
    _ADir := AddSlash(_ADir);
    if SetCurrentDir(_ADir) then
    begin
      Strs := TStringList.Create;
      try
        e := FindFirst('*',faDirectory, sr);
        while e = 0 do
        begin
          if ((sr.Attr and faDirectory) <> 0) and (not IsLink(_ADir +
sr.Name)) and (sr.Name[1] <> '.') then
            Strs.Add(_ADir + sr.Name);
          e := FindNext(sr);
        end;
        FindClose(sr);
        if Strs.Count > 0 then
          with Strs do
            for i:=Count-1 downto 0 do
              FindDirs(Strings[i]);
      finally
        Strs.Free;
      end;
    end;
  end;

var
  sr: TSearchRec;
  e: LongInt;
  Strs: TStrings;
  i: integer;
begin
  ADir := AddSlash(ADir);
  if SetCurrentDir(ADir) then
  begin
    Strs := TStringList.Create;
    try
      e := FindFirst('*', faDirectory, sr);
      while e = 0 do
      begin
        if ((sr.Attr and faDirectory) <> 0) and (not IsLink(ADir +
sr.Name)) and (sr.Name[1] <> '.')  then
          Strs.Add(ADir + sr.Name);
        e := FindNext(sr);
      end;
      FindClose(sr);
      //The corrected stuff if any one wonder...
      if Strs.Count > 0 then
        with Strs do
          for i:=Count-1 downto 0 do
            DoRest(Strings[i]);
    finally
      Strs.Free;
    end;
  end;
end;

-----------------------------------------------------------
:::::: remove x:es from email address
-----------------------------------------------------------
:::::: Sonket Dev: http://www.*-*-*.com/ ~u32102551/
:::::: Yo!Utilities II: http://www.*-*-*.com/ ~u32103496/
-----------------------------------------------------------



Thu, 20 Mar 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. FPC: recursive "FileFind"

2. The keys "-"/"+"/"*"

3. Prob: FPC Installation on "DOS 7"

4. ""256 Color Mouse""

5. What are "Denormals" and "Nans"

6. Utility to convert "asm" to "inline( )"

7. "delete from" followed by "insert into" = AV

8. "Replace Connection", "Unable to connect to: PARADOX".

9. HELP!!: "Multiple net files","Lock file has grown too large"

10. A problem in creating equal sized "packets" from a set of "packages".

11. How to make a "xxx.EXE" from the "xxx.PAS"???

12. "blob" and "DBT" file errors

 

 
Powered by phpBB® Forum Software