方法說明:
更改指定檔案描述符所引用檔案的時間戳,簡稱更改時間戳(同步版本)。
語法:
代碼如下:
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));
};