广州鸿名健康科技有限公司


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

网络编程 node.js中的fs.futimesSync方法使用说明 06-21

方法说明:

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

简称 更改时间戳

语法:

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.createWriteStream方法使用说明
方法说明:返回一个WriteStream(输出流)对象(可写流)。语法:fs.createWriteStream(path,[options])由于该方法属于fs模块,使用前需要引入fs模块(varfs=require(

node.js中的fs.createReadStream方法使用说明
方法说明:返回一个readStream(文件读取流,输入流)对象。(可读流)语法:fs.createReadStream(path,[options])由于该方法属于fs模块,使用前需要引入fs模块

node.js中的fs.appendFileSync方法使用说明
方法说明:该方法功能与fs.appendFile()类似,唯一区别就是该方法是用同步操作,而fs.appendFile使用的是异步。语法:fs.appendFileSync(filename,data,[options])由于


编辑:广州鸿名健康科技有限公司

标签:方法,模块,语法,使用说明,文件