_futime, _futime64
div
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

_futime, _futime64

Set modification time on an open file.

int _futime( 
   int fd,
   struct _utimbuf *filetime 
);
int _futime64( 
   int fd,
   struct __utimbuf64 *filetime 
);

Parameters

fd
File descriptor to open file.
filetime
Pointer to structure containing new modification date.

Return Value

Return 0 if successful. If an error occurs, return –1 and errno is set to EBADF, indicating an invalid file descriptor.

Remarks

The _futime routine sets the modification date and the access time on the open file associated with fd. _futime is identical to _utime, except that its argument is the file descriptor of an open file, rather than the name of a file or a path to a file. The _utimbuf structure contains fields for the new modification date and access time. Both fields must contain valid values.

_futime64, which uses the __utimbuf64 structure, can read and modify file dates through 23:59:59, December 31, 3000, UTC, whereas a call to _futime will fail if the date on the file is later than 19:14:07 January 18, 2038, UTC. Midnight, January 1, 1970, is the lower bound of the date range for these functions.

Requirements

Function Required header Optional headers Compatibility
_futime <sys/utime.h> <errno.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_futime64 <sys/utime.h> <errno.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example

// crt_futime.c
/* This program uses _futime64 to set the
 * file-modification time to the current time.
 */

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utime.h>

int main( void )
{

   int hFile;

   /* Show file time before and after. */
   system( "dir crt_futime.c" );

   hFile = _open("crt_futime.c", _O_RDWR);

   if( _futime64( hFile, NULL ) == -1 )
      perror( "_futime failed\n" );
   else
      printf( "File time modified\n" );

   close (hFile);

   system( "dir crt_futime.c" );

}

Sample Output

 Volume in drive C has no label.
 Volume Serial Number is E078-087A

 Directory of C:\Documents and Settings\user\My Documents

02/13/2002  09:06a                 620 crt_futime.c
               1 File(s)            620 bytes
               0 Dir(s)  15,475,073,024 bytes free
File time modified
 Volume in drive C has no label.
 Volume Serial Number is E078-087A

 Directory of C:\Documents and Settings\user\My Documents

02/13/2002  09:06a                 620 crt_futime.c
               1 File(s)            620 bytes
               0 Dir(s)  15,475,073,024 bytes free

See Also

Time Management Routines | Run-Time Routines and .NET Framework Equivalents

Show:
© 2016 Microsoft