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

方法说明:

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

简称 更改时间戳

语法:


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));

};