futime.c

来自「ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机」· C语言 代码 · 共 48 行

C
48
字号
/*
 * COPYRIGHT:   See COPYING in the top level directory
 * PROJECT:     ReactOS system libraries
 * FILE:        lib/crt/??????
 * PURPOSE:     Unknown
 * PROGRAMER:   Unknown
 * UPDATE HISTORY:
 *              25/11/05: Added license header
 */

#include <precomp.h>
#include <sys/utime.h>

/*
 * @implemented
 */
int _futime (int nHandle, struct _utimbuf *pTimes)
{
  FILETIME  LastAccessTime;
  FILETIME  LastWriteTime;

  // check for stdin / stdout  handles ??
  if (nHandle == -1) {
      __set_errno(EBADF);
      return -1;
  }

  if (pTimes == NULL) {
      pTimes = _alloca(sizeof(struct _utimbuf));
      time(&pTimes->actime);
      time(&pTimes->modtime);
  }

  if (pTimes->actime < pTimes->modtime) {
      __set_errno(EINVAL);
      return -1;
  }

  UnixTimeToFileTime(pTimes->actime,&LastAccessTime,0);
  UnixTimeToFileTime(pTimes->modtime,&LastWriteTime,0);
  if (!SetFileTime((HANDLE)_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime)) {
      __set_errno(EBADF);
      return -1;
  }

  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?