Share via


_futime

Sets modification time on an open file.

int_futime(inthandle**,struct_utimbuf*filetime);**

Function Required Header Optional Headers Compatibility
_futime <sys/utime.h> <errno.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

_futime returns 0 if successful. If an error occurs, this function returns –1 and errno is set to EBADF, indicating an invalid file handle.

Parameters

handle

Handle to open file

filetime

Pointer to structure containing new modification date

Remarks

The _futime routine sets the modification date and the access time on the open file associated with handle._futime is identical to _utime, except that its argument is the handle to 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.

Example

/* FUTIME.C: This program uses _futime 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>

void main( void )
{

   int hFile;

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

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

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

   close (hFile);

   system( "dir futime.c" );

}

Output

 Volume in drive C is CDRIVE
 Volume Serial Number is 1D37-7A7A

 Directory of C:\code

05/03/95  01:30p                   601 futime.c
               1 File(s)            601 bytes
                             16,269,312 bytes free
 Volume in drive C is CDRIVE
 Volume Serial Number is 1D37-7A7A

 Directory of C:\code

05/03/95  01:36p                   601 futime.c
               1 File(s)            601 bytes
                             16,269,312 bytes free
File time modified

Time Management Routines