home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / TREEDIR.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  893b  |  37 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  TREEDIR.C - simple recursive directory lister
  5. **
  6. **  public domain demo by Bob Stout
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "sniptype.h"
  12. #include "dirport.h"
  13.  
  14. void do_dir(char *path)
  15. {
  16.       char search[67], newpath[67];
  17.       DOSFileData ff;
  18.  
  19.       strcat(strcpy(search, path), "\\*.*");
  20.       if (Success_ == FIND_FIRST(search, _A_ANY, &ff)) do
  21.       {
  22.             printf("%s\\%s\n", path, ff_name(&ff));
  23.             if (ff_attr(&ff) & _A_SUBDIR && '.' != *ff_name(&ff))
  24.             {
  25.                   strcat(strcat(strcpy(newpath, path), "\\"), ff_name(&ff));
  26.                   do_dir(newpath);
  27.             }
  28.       } while (Success_ == FIND_NEXT(&ff));
  29.       FIND_END(&ff);
  30. }
  31.  
  32. main()                  /* simple recursive current directory lister    */
  33. {
  34.       do_dir(".");
  35.       return 0;
  36. }
  37.