Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - dos_setftime http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                               dos_setftime

   Usage
   #include <dos.h>
   int dos_setftime(int fd, unsigned date, unsigned time);

   Description
   Sets the time and date of the file attatched to the file descriptor fd
   to those specified in the arguments date and time. The format of these
   arguments  is the same as those which are obtained by the use  of  the
   dos_getftime function.

   date:
   bits 0 to 4    day of month (0-31)
   bits 5 to 8    month (0-12)
   bits 9 to 15   year (relative to 1980)
   time:
   bits 0 to 4    no of 2 second increments (0-29)
   bits 5 to 10   minutes (0-59)
   bits 11 to 15  hours (0-23)

   Example
   #include <stdio.h>
   #include <dos.h>
   #include <io.h>

   main()
   {
   int fd, d,m,y,h,mi,s;
   unsigned date, time;

        printf("Creating temporary file\n");
        fd = dos_creat("temp.fil",FA_RDONLY);
        if(fd == -1)
        {
             perror("Error opening file");
             exit(1);
        }
        dos_getftime(fd,&date,&time);
        d = date & 0b11111;
        m = (date >> 5)  & 0b1111;
        y = ((date >> 9) & 0b1111111) + 1980;
        s = (time & 0b11111)*2;
        mi = (time >> 5)  & 0b111111;
        h = (time >> 11) & 0b11111;
        close(fd);
        printf("temp.fil date = %02d/%02d/%02d\n",m,d,y);
        printf("         time = %02d:%02d:%02d\n",h,mi,s);

        if(unlink("temp.fil") == 0)
             printf("\nTemporary file successfully deleted\n");
        else
             perror("Error deleting file:");
   }

   Return Value
   0 if successful, otherwise returns the DOS error code.


See Also: DOS_Package dos_getftime

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson