_futime, _futime32, _futime64

開いているファイルの変更時刻を設定します。

構文

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

パラメーター

fd
開いているファイルのファイル記述子。

filetime
新しい変更日を含む構造体へのポインター。

戻り値

処理が正常に終了した場合は 0 を返します。 エラーが発生した場合、「パラメーターの検証」で説明されているように、無効なパラメーター ハンドラーが呼び出されます。 実行の続行が許可されている場合、関数は -1 をEBADF返しerrno、無効なファイル記述子を示すか、無効EINVALなパラメーターを示す -1 に設定されます。

解説

ルーチンは _futime 、関連付けられている fd開いているファイルの変更日とアクセス時間を設定します。 _futime は、引数がファイルの名前またはファイルへのパスではなく、開いているファイルのファイル記述子であることを除き、同じです _utime_utimbuf 構造体には、新しい変更日とアクセス時間のフィールドが含まれています。 両方のフィールドに、有効な値が含まれている必要があります。 _utimbuf32 および _utimbuf64_utimbuf と同じですが、それぞれを 32 ビットおよび 64 ビットの時刻の型を使用する点が異なります。 _futime および _utimbuf は、64 ビット時刻型を使用し、_futime の動作は _futime64 と同じです。 古い動作を強制的に実行させる必要がある場合は、_USE_32BIT_TIME_T を定義します。 これにより、_futime の動作が _futime32 と同じになり、_utimbuf 構造帯が、32 ビットの時間型を使用し、__utimbuf32 と等しくなります。

__utimbuf64 構造体を使用する _futime64 は、UTC の 3000 年 12 月 31 日 23時 59分: 59 秒までのファイル日付を読み取りおよび変更できますが、これに対して _futime32 の呼び出しは、ファイルの日付が UTC の 2038 年 1 月 18 日 23 時 59分: 59 秒よりも後の場合は失敗します。 これらの関数の日付範囲の下限は、1970 年 1 月 1 日の午前 0 時です。

既定では、この関数のグローバル状態の適用対象は、アプリケーションになります。 この動作を変更するには、「CRT のグローバル状態」を参照してください

必要条件

機能 必須ヘッダー オプション ヘッダー
_futime <sys/utime.h> <errno.h>
_futime32 <sys/utime.h> <errno.h>
_futime64 <sys/utime.h> <errno.h>

互換性の詳細については、「 Compatibility」を参照してください。

// crt_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>
#include <share.h>

int main( void )
{
   int hFile;

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

   _sopen_s( &hFile, "crt_futime.c_input", _O_RDWR, _SH_DENYNO, 0 );

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

   _close (hFile);

   system( "dir crt_futime.c_input" );
}

Input: crt_futime.c_input

Arbitrary file contents.

サンプル出力

Volume in drive Z has no label.
Volume Serial Number is 5C68-57C1

Directory of Z:\crt

03/25/2004  10:40 AM                24 crt_futime.c_input
               1 File(s)             24 bytes
               0 Dir(s)  24,268,476,416 bytes free
Volume in drive Z has no label.
Volume Serial Number is 5C68-57C1

Directory of Z:\crt

03/25/2004  10:41 AM                24 crt_futime.c_input
               1 File(s)             24 bytes
               0 Dir(s)  24,268,476,416 bytes free
File time modified

関連項目

時間管理