home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / utils / charset / touchr.c < prev   
Encoding:
C/C++ Source or Header  |  1994-08-27  |  761 b   |  26 lines

  1. /* Copies the date from one file to another file. */
  2. /* "touchr file1 file2" is equivalent to
  3.    "touch -r file1 file2", assuming GNU touch. */
  4. /* Bruno Haible 8.7.1994 */
  5.  
  6. #include <sys/types.h>
  7. #include <sys/stat.h> /* stat */
  8. #include <sys/time.h> /* struct timeval, utimes */
  9. #include <errno.h> /* EINTR, perror */
  10.  
  11. int main (argc,argv)
  12.   int argc;
  13.   char* argv[];
  14. { if (argc != 1+2) { exit(1); }
  15.  {char* filename1 = argv[1];
  16.   char* filename2 = argv[2];
  17.   struct stat statbuf;
  18.   struct timeval tv[2];
  19.   if (stat(filename1,&statbuf) < 0) { perror(filename1); exit(1); }
  20.   tv[0].tv_sec = statbuf.st_atime; tv[0].tv_usec = 0;
  21.   tv[1].tv_sec = statbuf.st_mtime; tv[1].tv_usec = 0;
  22.   if (utimes(filename2,tv) < 0) { perror(filename2); exit(1); }
  23.   exit(0);
  24. }}
  25.  
  26.