node.js中的fs.futimesSync方法使用说明

2019-12-18,,

方法说明:

更改一个文件所提供的文件描述符引用的文件的时间戳。

简称 更改时间戳

语法:

复制代码 代码如下:
fs.futimes(fd, atime, mtime, callback)

由于该方法属于fs模块,使用前需要引入fs模块(var fs= require(“fs”) )

接收参数:

fd             标识符

atime

mtime

callback   回调

例子:

复制代码 代码如下:
fs.open('/path/demo1.txt', 'a', function (err, fd) {
  if (err) {
    throw err;
  }
  fs.futimes(fd, 1388648322, 1388648322, function (err) {
    if (err) {
      throw err;
    }
    console.log('futimes complete');
    fs.close(fd, function () {
      console.log('Done');
    });
  });
});

源码:

复制代码 代码如下:
fs.futimes = function(fd, atime, mtime, callback) {
  atime = toUnixTimestamp(atime);
  mtime = toUnixTimestamp(mtime);
  binding.futimes(fd, atime, mtime, makeCallback(callback));
};

您可能感兴趣的文章:

  • node.js用fs.rename强制重命名或移动文件夹的方法
  • node.js基于fs模块对系统文件及目录进行读写操作的方法详解
  • 基于node.js的fs核心模块读写文件操作(实例讲解)
  • node.js中fs.stat与fs.fstat的区别详解
  • 浅谈Node.js:fs文件系统模块
  • node.js中的fs.chmodSync方法使用说明
  • node.js中的fs.chmod方法使用说明
  • node.js中的fs.appendFile方法使用说明
  • node.js中的fs.appendFileSync方法使用说明
  • node.js中的fs.createWriteStream方法使用说明
  • node.js中fs文件系统目录操作与文件信息操作

《node.js中的fs.futimesSync方法使用说明.doc》

下载本文的Word格式文档,以方便收藏与打印。