home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / DIRFIND.ZIP / DIRFIND.PAS next >
Encoding:
Pascal/Delphi Source File  |  1988-10-24  |  1.3 KB  |  47 lines

  1. unit dirfind;
  2. { a unit to make searching for subdirectories a bit easier, since DOS won't
  3. do an exclusive directory search }
  4. { released into the public domain 24-OCT-88 by Bob Hodge,
  5.     Country Basket Software }
  6.  
  7. {The two functions work much like Turbo's FindFirst & FindNext procedures,
  8. but return a boolean to make your program logic a little smoother }
  9. { It works for me, at least! }
  10.  
  11. interface
  12.  
  13. uses DOS;
  14.  
  15. function FindFirstDir( source : string; var SearchDTA : searchrec ): boolean ;
  16. { returns TRUE if a directory was found, FALSE otherwise }
  17. { (of course, SearchDTA will be modified as well) }
  18.  
  19. function FindNextDir( var SearchDTA : searchrec): boolean;
  20.  
  21. { ************************************************************************** }
  22. implementation
  23.  
  24. function FindNextDir{( var SearchDTA : searchrec): boolean};
  25. begin
  26.     FindNext( SearchDTA);
  27.     while (DosError = 0) AND ((SearchDTA.Attr AND Directory) = 0) do
  28.           FindNext( SearchDTA);
  29.     if DosError = 0 then
  30.         FindNextDir := TRUE
  31.     else
  32.         FindNextDir := FALSE;
  33. end;
  34.  
  35.  
  36. function FindFirstDir{( source : string; var SearchDTA : searchrec ): boolean};
  37. begin
  38.     FindFirst( source, Directory + Hidden, SearchDTA);
  39.     while (DosError = 0) AND ((SearchDTA.Attr AND Directory) = 0) do
  40.           FindNext( SearchDTA);
  41.     if DosError = 0 then
  42.         FindFirstDir := TRUE
  43.     else
  44.         FindFirstDir := FALSE;
  45. end;
  46.  
  47. end.