_dos_getftime, _dos_setftime
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
| DOS | UNIX | Windows | ANSI C | C++ 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-4 | Day |
| bits 5-8 | Month |
| bits 9-15 | Years since 1980 (e.g., 9 here means 1989) |
Time:
| bits 0-4 | The result of seconds divided by 2 (e.g., 10 here means 20 seconds) |
| bits 5-10 | Minutes |
| bits 11-15 | Hours |
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:
| EBADF | Bad file number |
See also
fstatStat
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`
Stable link: /3.1/dos.h/_dos_getftime/
· short form /3.1/_dos_getftime/