Borland C++ reference

_dos_getftime, _dos_setftime

raw OCR

Gets and sets file date and time.

Defined in header <dos.h>

Syntax

#include <dos.h>
unsigned  _dos_getftime(int handle, unsigned *datep,unsigned *tiniep);
unsigned  _dos_setftime(int handle, unsigned date,unsigned time);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

_dos_getftime retrieves the file time and date for the disk file associated with the open handle. The file must have been previously opened using _dos_open, _dos_creat, or _dos_creatnew. _dos_getftime stores the date and time at the locations pointed to by datep and timep.

_dos_setftime sets the file's new date and time values as specified by date and time.

Note that the date and time values contain bit fields for referring to the file's date and time. The structure of these fields was established by DOS. Both are 16-bit structures divided into three fields.

Date:

bits 0-4Day
bits 5-8Month
bits 9-15Years since 1980 (e.g., 9 here means 1989)

Time:

bits 0-4The result of seconds divided by 2 (e.g., 10 here means 20 seconds)
bits 5-10Minutes
bits 11-15Hours

Return value

_dos_getftime and _dos_setftime return 0 on success.

In the event of an error return, the DOS error code is returned and the global variable errno is set to the following:

EBADFBad file number

See also

Example

#include <stdio.h>
#include <dos.h>
int main(void)
{
   FILE *stream;
   unsigned date, time;
   if {(stream = fopen ("TEST.$$$", "w")) == NULL) {
      fprintf(stderr, "Cannot open output file.\n");
      return 1;
   }
   _dos_getftime(fileno (stream), &date, &time);
   printfC'File year of TEST.$$$: %d\n",((date »   9) & 0x7f) + 19*
   date = (date & Oxlff)  I (21 « 9);
   _dos_setftime(fileno (stream), date, time);
   printf("Set file year to 2001.\n");
   fclose(stream);
   return 0;
}

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `_dos_getftime, _dos_setffinne` read as `_dos_getftime, _dos_setftime`