home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / SETIMETO.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  49 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  SETIMETO.C - Set the timestamp of one file to match another.
  5. **
  6. **  public domain demo by Bob Stout
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <dos.h>
  12. #include <io.h>
  13. #include <fcntl.h>
  14. #include "ftime.h"
  15.  
  16. int main(int argc, char *argv[])
  17. {
  18.       int fd0, fd1;
  19.  
  20.       struct ftime Ftime;
  21.  
  22.       if (3 > argc)
  23.       {
  24.             puts("Usage: SETIMETO filename_w/original_stamp "
  25.                   "filename_w/stamp_to_set");
  26.             return EXIT_FAILURE;
  27.       }
  28.  
  29.       if (-1 == (fd0 = open(argv[1], O_RDONLY)))
  30.       {
  31.             printf("Unable to open %s\n", argv[1]);
  32.             return EXIT_FAILURE;
  33.       }
  34.  
  35.       getftime(fd0, &Ftime);              /* Save the time/date         */
  36.  
  37.       if (-1 == (fd1 = open(argv[2], O_WRONLY)))
  38.       {
  39.             printf("Unable to open %s\n", argv[2]);
  40.             return EXIT_FAILURE;
  41.       }
  42.  
  43.       setftime(fd1, &Ftime);              /* Set the time/date          */
  44.  
  45.       close(fd0);
  46.       close(fd1);
  47.       return EXIT_SUCCESS;
  48. }
  49.