home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / uucp / Uucp.framework / unix.subproj / walk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-09  |  1.0 KB  |  59 lines

  1. /* walk.c
  2.    Walk a directory tree.  */
  3.  
  4. #include "uucp.h"
  5.  
  6. #include "uudefs.h"
  7. #include "sysdep.h"
  8. #include "system.h"
  9.  
  10. #if HAVE_FTW_H
  11. #include <ftw.h>
  12. #endif
  13.  
  14. static int iswalk_dir P((const char *zname, struct stat *qstat, int iflag));
  15.  
  16. /* Walk a directory tree.  */
  17.  
  18. static size_t cSlen;
  19. static void (*puSfn) P((const char *zfull, const char *zrelative,
  20.             pointer pinfo));
  21. static pointer pSinfo;
  22.  
  23. boolean
  24. usysdep_walk_tree (zdir, pufn, pinfo)
  25.      const char *zdir;
  26.      void (*pufn) P((const char *zfull, const char *zrelative,
  27.              pointer pinfo));
  28.      pointer pinfo;
  29. {
  30.   cSlen = strlen (zdir) + 1;
  31.   puSfn = pufn;
  32.   pSinfo = pinfo;
  33.   return ftw ((char *) zdir, iswalk_dir, 5) == 0;
  34. }
  35.  
  36. /* Pass a file found in the directory tree to the system independent
  37.    function.  */
  38.  
  39. /*ARGSUSED*/
  40. static int
  41. iswalk_dir (zname, qstat, iflag)
  42.      const char *zname;
  43.      struct stat *qstat;
  44.      int iflag;
  45. {
  46.   char *zcopy;
  47.  
  48.   if (iflag != FTW_F)
  49.     return 0;
  50.  
  51.   zcopy = zbufcpy (zname + cSlen);
  52.  
  53.   (*puSfn) (zname, zcopy, pSinfo);
  54.  
  55.   ubuffree (zcopy);
  56.  
  57.   return 0;
  58. }
  59.