Home  >  Article  >  Web Front-end  >  node.js中的fs.utimesSync方法使用说明_node.js

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

WBOY
WBOYOriginal
2016-05-16 16:27:041256browse

方法说明:

同步版的 utimes() ,同步方式修改文件时间戳。

语法:

复制代码 代码如下:

fs.utimesSync(path, atime, mtime)

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

接收参数:

path           文件路径

mtime        修改时间 ,表示文件被修改的时间和日期。文件的内容发生改变时,文件的修改日期将随之更新

atime         访问时间 ,表示文件最后被访问的时间和日期。 每一次应用程序或服务使用系统调用,读取一个文件时,文件的访问时间都会更新。

例子:

复制代码 代码如下:

var fs = require('fs');
fs.utimesSync('125.txt', atime, mtime);

源码:

复制代码 代码如下:

fs.utimesSync = function(path, atime, mtime) {
  nullCheck(path);
  atime = toUnixTimestamp(atime);
  mtime = toUnixTimestamp(mtime);
  binding.utimes(pathModule._makeLong(path), atime, mtime);
};
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn