Borland C++ reference

getftime, setftime

raw OCR

Gets and set the file date and time.

Defined in header <io.h>

Syntax

#include <io.h>
int getftime(int handle, struct ftime *ftimep);
int setftime(int handle, struct ftime *ftimep);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

getftime retrieves the file time and date for the disk file associated with the open handle. The ftime structure pointed to by ftimep is filled in with the file's time and date.

setftime sets the file date and time of the disk file associated with the open handle to the date and time in the ftime structure pointed to by ftimep. The file must not be written to after the setftime call or the changed information will be lost.

The ftime structure is defined as follows:

struct ftime {

unsigned ft_tsec: 5;/*two seconds */
unsigned ft_min: 6;/*minutes */
unsigned ft_hour: 5;/*hours */
unsigned ft_day: 5;/*days */
unsigned ft_month: 4;/*months */
unsigned ft_year: 7;/*year - 1980V

Return value

getftime and setftime return 0 on success.

In the event of an error return, -1 is returned and the global variable errno is set to one of the following:

EINVFNC Invalid function number

EBADFBad file number

See also

Example

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

mt  main!

    FILE *stream;
    struct ftime ft;

    printf("Creating new  file TEST.$$$\n");
    if ((stream = fopen("TEST.$$$",  "wt")) == NULL) {
        printf ("Cannot open output file.\n");
        return 1;
    }
    if (getftime(fileno(stream) , Sift) != 0) { .
        perror("Unable  to get file time");
        return 1;
printfC'File time:  %02u:%02u:%02u\n",
        ft.ft_hour,  ft.ft_min, ft.ft_tsec * 2);
printf("File date:  %02u/%02u/%04u\n",
        ft.ft_month,  ft.ft_day, ft.ft_Year+1980
printf ("Setting file year to 2001.\n");
ft.ft_year = 2001  - 1980;
if  (setftime(fileno(stream), &ft) != 0)
    perror( "Unable to set file time");
fclose (stream);
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.