[BACK]Return to function.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / find

Diff for /src/usr.bin/find/function.c between version 1.6 and 1.7

version 1.6, 1996/09/01 04:30:17 version 1.7, 1996/09/01 04:56:26
Line 47 
Line 47 
 #include <sys/wait.h>  #include <sys/wait.h>
 #include <sys/mount.h>  #include <sys/mount.h>
   
   #include <dirent.h>
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <fnmatch.h>  #include <fnmatch.h>
Line 213 
Line 214 
         return (palloc(N_DEPTH, f_always_true));          return (palloc(N_DEPTH, f_always_true));
 }  }
   
   /*
    * -empty functions --
    *
    *      True if the file or directory is empty
    */
   int
   f_empty(plan, entry)
           PLAN *plan;
           FTSENT *entry;
   {
           if (S_ISREG(entry->fts_statp->st_mode) && entry->fts_statp->st_size == 0)
                   return (1);
           if (S_ISDIR(entry->fts_statp->st_mode)) {
                   struct dirent *dp;
                   int empty;
                   DIR *dir;
   
                   empty = 1;
                   dir = opendir(entry->fts_accpath);
                   if (dir == NULL)
                           err(1, "%s", entry->fts_accpath);
                   for (dp = readdir(dir); dp; dp = readdir(dir))
                           if (dp->d_name[0] != '.' ||
                               (dp->d_name[1] != '\0' &&
                                (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) {
                                   empty = 0;
                                   break;
                           }
                   closedir(dir);
                   return (empty);
           }
           return (0);
   }
   
   PLAN *
   c_empty()
   {
           ftsoptions &= ~FTS_NOSTAT;
   
           return (palloc(N_EMPTY, f_empty));
   }
   
 /*  /*
  * [-exec | -ok] utility [arg ... ] ; functions --   * [-exec | -ok] utility [arg ... ] ; functions --
  *   *

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7