www.delorie.com/djgpp/doc/libc/libc_181.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

_dos_setftime

Syntax

 
#include <dos.h>

unsigned int _dos_setftime(int handle,
                           unsigned int date, unsigned time);

Description

This function sets the date and time of the given file. The meaning of DOS date in the date variable is the following:

 
F E D C B A 9 8 7 6 5 4 3 2 1 0 (bits)
x x x x x x x x x x x x x x x x
*-----------* *-----* *-------*
    year       month     day

year  = 0-119 (relative to 1980)
month = 1-12
day   = 1-31

The meaning of DOS time in the time variable is the following:

 
F E D C B A 9 8 7 6 5 4 3 2 1 0 (bits)
x x x x x x x x x x x x x x x x
*-------* *---------* *-------*
  hours     minutes    seconds

hours   = 0-23
minutes = 0-59
seconds = 0-29 in two-second intervals

See section _dos_getftime.

This function cannot be used to set the last access date and time, even on systems where the LFN API (see section LFN) is available. For LFN-aware functions with similar functionality see utime, which is Posix-standard, and see utimes.

Return Value

Returns 0 if successful and return DOS error on error (and sets errno=EBADF).

Portability

ANSI/ISO C No
POSIX No

Example

 
struct dosdate_t d;
struct dostime_t t;
unsigned int handle, date, time;

_dos_open("FOO.DAT", O_RDWR, &handle);
_dos_getdate(&d);
_dos_gettime(&t);
date = ((d.year - 1980) << 9) | (d.month << 5) | d.day;
time = (t.hour << 11) | (t.minute << 5) | (t.second / 2);
_dos_setftime(handle, date, time);
_dos_close(handle);


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004