home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / TOUCH.C < prev    next >
C/C++ Source or Header  |  1991-08-11  |  1KB  |  46 lines

  1. /*----------------------------------------------------------------------*
  2. * Program:     touch                                                    *
  3. * Programmer:  Ray L. McVay                                             *
  4. * Started:     8 Aug 91                                                 *
  5. * Updated:                                                              *
  6. *-----------------------------------------------------------------------*
  7. * Simple touch program to test BC time stamping function.               *
  8. * Public Domain                                                         *
  9. *----------------------------------------------------------------------*/
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #include <io.h>
  14.  
  15. main(int argc, char **argv)
  16. {
  17.     struct date cd;
  18.     struct time ct;
  19.     struct ftime ft;
  20.     FILE *f;
  21.  
  22.     if (argc > 1)
  23.     {
  24.        getdate(&cd);
  25.        gettime(&ct);
  26.        ft.ft_year = cd.da_year;
  27.        ft.ft_month = cd.da_mon;
  28.        ft.ft_day = cd.da_day;
  29.        ft.ft_hour = ct.ti_hour;
  30.        ft.ft_min = ct.ti_min;
  31.        ft.ft_tsec = ct.ti_sec/2;
  32.  
  33.        if ((f = fopen(argv[1], "r+b")) != NULL)
  34.            setftime(fileno(f), &ft);
  35.        else if ((f = fopen(argv[1], "w")) != NULL)
  36.            setftime(fileno(f), &ft);
  37.        else
  38.            perror("Can't open file");
  39.  
  40.        if (f)
  41.            fclose(f);
  42.     }
  43.  
  44.     return 0;
  45. }
  46.