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

Diff for /src/usr.bin/cvs/file.c between version 1.43 and 1.44

version 1.43, 2004/12/13 19:38:22 version 1.44, 2004/12/14 21:23:44
Line 536 
Line 536 
         CVSFILE *cfp;          CVSFILE *cfp;
         struct stat st;          struct stat st;
         struct cvs_dir *cdp;          struct cvs_dir *cdp;
           struct cvs_ent *cvsent;
         struct cvs_flist dirs;          struct cvs_flist dirs;
   
         ndirs = 0;          ndirs = 0;
Line 577 
Line 578 
                 return (-1);                  return (-1);
         }          }
   
           /* To load all files, we first get the entries for the directory and
            * load the information for each of those entries.  The handle to
            * the Entries file kept in the directory data is only temporary and
            * the files should remove their entry when they use it.  After all
            * files in the directory have been processed, the Entries handle
            * should only be left with those entries for which no real file
            * exists.  We then build file structures for those files too, as
            * we will likely receive fresh copies from the server as part of the
            * response.
            */
         do {          do {
                 ret = getdirentries(fd, fbuf, sizeof(fbuf), &base);                  ret = getdirentries(fd, fbuf, sizeof(fbuf), &base);
                 if (ret == -1) {                  if (ret == -1) {
Line 616 
Line 627 
         } while (ret > 0);          } while (ret > 0);
   
         if (cdp->cd_ent != NULL) {          if (cdp->cd_ent != NULL) {
                   /* now create file structure for files which have an
                    * entry in the Entries file but no file on disk
                    */
                   while ((cvsent = cvs_ent_next(cdp->cd_ent)) != NULL) {
                           snprintf(pbuf, sizeof(pbuf), "%s/%s", fpath,
                               cvsent->ce_name);
                           cfp = cvs_file_lget(pbuf, flags, cf);
                           if (cfp != NULL) {
                                   if (cfp->cf_type == DT_DIR) {
                                           TAILQ_INSERT_TAIL(&dirs, cfp, cf_list);
                                           ndirs++;
                                   } else {
                                           TAILQ_INSERT_TAIL(&(cdp->cd_files), cfp,
                                               cf_list);
                                           cdp->cd_nfiles++;
                                   }
                           }
                   }
                 cvs_ent_close(cdp->cd_ent);                  cvs_ent_close(cdp->cd_ent);
                 cdp->cd_ent = NULL;                  cdp->cd_ent = NULL;
         }          }
Line 835 
Line 864 
 static CVSFILE*  static CVSFILE*
 cvs_file_lget(const char *path, int flags, CVSFILE *parent)  cvs_file_lget(const char *path, int flags, CVSFILE *parent)
 {  {
         int cwd;          int ret, cwd;
           u_int type;
         struct stat st;          struct stat st;
         CVSFILE *cfp;          CVSFILE *cfp;
         struct cvs_ent *ent = NULL;          struct cvs_ent *ent = NULL;
   
         if (strcmp(path, ".") == 0)          type = DT_UNKNOWN;
                 cwd = 1;          cwd = (strcmp(path, ".") == 0) ? 1 : 0;
         else  
                 cwd = 0;  
   
         if (stat(path, &st) == -1) {          ret = stat(path, &st);
                 cvs_log(LP_ERRNO, "failed to stat %s", path);          if (ret == 0)
                 return (NULL);                  type = IFTODT(st.st_mode);
         }  
   
         cfp = cvs_file_alloc(path, IFTODT(st.st_mode));          if ((cfp = cvs_file_alloc(path, type)) == NULL)
         if (cfp == NULL)  
                 return (NULL);                  return (NULL);
         cfp->cf_parent = parent;          cfp->cf_parent = parent;
         cfp->cf_mode = st.st_mode & ACCESSPERMS;  
         cfp->cf_mtime = st.st_mtime;  
   
         if ((parent != NULL) && (CVS_DIR_ENTRIES(parent) != NULL)) {          if ((parent != NULL) && (CVS_DIR_ENTRIES(parent) != NULL))
                 ent = cvs_ent_get(CVS_DIR_ENTRIES(parent), CVS_FILE_NAME(cfp));                  ent = cvs_ent_get(CVS_DIR_ENTRIES(parent), CVS_FILE_NAME(cfp));
         }  
   
         if (ent == NULL) {          if (ret == 0) {
                 cfp->cf_cvstat = (cwd == 1) ?                  cfp->cf_mode = st.st_mode & ACCESSPERMS;
                     CVS_FST_UPTODATE : CVS_FST_UNKNOWN;                  cfp->cf_mtime = st.st_mtime;
         } else {  
                 /* always show directories as up-to-date */                  if (ent == NULL)
                 if (ent->ce_type == CVS_ENT_DIR)                          cfp->cf_cvstat = (cwd == 1) ?
                         cfp->cf_cvstat = CVS_FST_UPTODATE;                              CVS_FST_UPTODATE : CVS_FST_UNKNOWN;
                 else if (rcsnum_cmp(ent->ce_rev, cvs_addedrev, 2) == 0)  
                         cfp->cf_cvstat = CVS_FST_ADDED;  
                 else {                  else {
                         /* check last modified time */                          /* always show directories as up-to-date */
                         if (ent->ce_mtime >= (time_t)st.st_mtime)                          if (ent->ce_type == CVS_ENT_DIR)
                                 cfp->cf_cvstat = CVS_FST_UPTODATE;                                  cfp->cf_cvstat = CVS_FST_UPTODATE;
                         else                          else if (rcsnum_cmp(ent->ce_rev, cvs_addedrev, 2) == 0)
                                 cfp->cf_cvstat = CVS_FST_MODIFIED;                                  cfp->cf_cvstat = CVS_FST_ADDED;
                           else {
                                   /* check last modified time */
                                   if (ent->ce_mtime >= (time_t)st.st_mtime)
                                           cfp->cf_cvstat = CVS_FST_UPTODATE;
                                   else
                                           cfp->cf_cvstat = CVS_FST_MODIFIED;
                           }
   
                           cvs_ent_remove(CVS_DIR_ENTRIES(parent),
                               CVS_FILE_NAME(cfp));
                 }                  }
           } else {
                   if (ent == NULL) {
                           cvs_log(LP_ERR, "no Entry and no file for `%s'",
                               CVS_FILE_NAME(cfp));
                           cvs_file_free(cfp);
                           return (NULL);
                   } else
                           cfp->cf_cvstat = CVS_FST_LOST;
         }          }
   
         if ((cfp->cf_type == DT_DIR) && (cvs_file_getdir(cfp, flags) < 0)) {          if ((cfp->cf_type == DT_DIR) && (cvs_file_getdir(cfp, flags) < 0)) {

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44