這篇文章主要介紹了node.js中的fs.futimes方法使用說明,本文介紹了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));
};