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

Diff for /src/usr.bin/rcs/rcsutil.c between version 1.47 and 1.48

version 1.47, 2020/10/14 20:07:19 version 1.48, 2023/08/11 05:02:21
Line 44 
Line 44 
  * rcs_get_mtime()   * rcs_get_mtime()
  *   *
  * Get <filename> last modified time.   * Get <filename> last modified time.
  * Returns last modified time on success, or -1 on failure.   * Returns last modified time on success, or a timespec with tv_nsec
    * set to UTIME_OMIT on failure.
  */   */
 time_t  struct timespec
 rcs_get_mtime(RCSFILE *file)  rcs_get_mtime(RCSFILE *file)
 {  {
         struct stat st;          struct stat st;
         time_t mtime;          struct timespec mtime = { .tv_sec = 0, .tv_nsec = UTIME_OMIT };
   
         if (file->rf_file == NULL)          if (file->rf_file == NULL)
                 return (-1);                  return mtime;
   
         if (fstat(fileno(file->rf_file), &st) == -1) {          if (fstat(fileno(file->rf_file), &st) == -1) {
                 warn("%s", file->rf_path);                  warn("%s", file->rf_path);
                 return (-1);                  return mtime;
         }          }
   
         mtime = st.st_mtimespec.tv_sec;          return st.st_mtim;
   
         return (mtime);  
 }  }
   
 /*  /*
  * rcs_set_mtime()   * rcs_set_mtime()
  *   *
  * Set <filename> last modified time to <mtime> if it's not set to -1.   * Set <filename> last modified time to <mtime> if its tv_nsec isn't UTIME_OMIT
  */   */
 void  void
 rcs_set_mtime(RCSFILE *file, time_t mtime)  rcs_set_mtime(RCSFILE *file, struct timespec mtime)
 {  {
         static struct timeval tv[2];          struct timespec ts[2];
   
         if (file->rf_file == NULL || mtime == -1)          if (file->rf_file == NULL || mtime.tv_nsec == UTIME_OMIT)
                 return;                  return;
   
         tv[0].tv_sec = mtime;          ts[0] = ts[1] = mtime;
         tv[1].tv_sec = tv[0].tv_sec;  
   
         if (futimes(fileno(file->rf_file), tv) == -1)          if (futimens(fileno(file->rf_file), ts) == -1)
                 err(1, "utimes");                  err(1, "utimes");
 }  }
   

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48