Subversion Repositories svn.Prod repos

Rev

Rev 30 | Rev 37 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. program filefind;
  2. Uses    sysutils;
  3. var     directory : string;
  4.  
  5. // ============================================================================
  6. // Functions
  7. // ============================================================================
  8.  
  9. procedure traverse(directory : string);
  10. var     curdir1, curdir2 : string;
  11.         Info : TSearchRec;
  12.         pfile : string;
  13. begin
  14.         curdir1 := GetCurrentDir;
  15.         chdir(directory);
  16.         curdir2 := GetCurrentDir;
  17.         FindFirst(directory + '/*', faAnyFile or faHidden, Info);
  18.         repeat
  19.                 if ((Info.name <> '..') and (Info.name <> '.'))
  20.                 then
  21.                         begin
  22.                         pfile := curdir2 + '/' + Info.name;
  23.                         Writeln(pfile);
  24.                         if (DirectoryExists(pfile))
  25.                         then
  26.                                 traverse(pfile)
  27.                         end
  28.         until FindNext(Info) <> 0;
  29.         chdir(curdir1);
  30. end;
  31.  
  32. procedure start_traverse(directory : string);
  33. begin
  34.         Writeln(directory);
  35.         traverse(directory);
  36. end;
  37.  
  38. // ============================================================================
  39. // Main
  40. // ============================================================================
  41.  
  42. begin
  43.         directory := ParamStr(1);
  44.         if (ParamCount = 1)
  45.         then
  46.                 if DirectoryExists(directory)
  47.                 then
  48.                         start_traverse(directory)
  49.                 else
  50.                         Writeln ('ERROR: Not a directory : ', directory)
  51.         else
  52.                 Writeln('ERROR: Give directory as argument');
  53. end.
  54.