How to use the futimes function from fs

Find comprehensive JavaScript fs.futimes code examples handpicked from public code repositorys.

111
112
113
114
115
116
117
118
119
  fd = fs.openSync(tmpdir.path, 'r+');
} else {
  fd = fs.openSync(tmpdir.path, 'r');
}

fs.futimes(fd, atime, mtime, common.mustCall((err) => {
  expect_ok('futimes', fd, err, atime, mtime);

  syncTests();
fork icon42
star icon19
watch icon0

+ 5 other calls in file

838
839
840
841
842
843
844
845
846
847
  assert.strictEqual(err.syscall, 'futime');
  return true;
};

common.runWithInvalidFD((fd) => {
  fs.futimes(fd, new Date(), new Date(), common.mustCall(validateError));

  assert.throws(
    () => fs.futimesSync(fd, new Date(), new Date()),
    validateError
fork icon42
star icon19
watch icon0

411
412
413
414
415
416
417
418
419

if (entry.mtime && !this.noMtime) {
  actions++
  const atime = entry.atime || new Date()
  const mtime = entry.mtime
  fs.futimes(fd, atime, mtime, er =>
    er ? fs.utimes(abs, atime, mtime, er2 => done(er2 && er))
    : done())
}
fork icon3
star icon2
watch icon0

114
115
116
117
118
119
120
121
122
123
124


function futime() {
  const fs = require('fs');
  fs.writeFileSync('fs11.txt', '123', 'utf8');
  const fd = fs.openSync('fs11.txt', 'r+');
  fs.futimes(fd, 1, 1, () => {
    fs.unlinkSync('fs11.txt');
  });
}

fork icon0
star icon0
watch icon0

+ 2 other calls in file

125
126
127
128
129
130
131
132
133
134
}

fs.futimes(fd, atime, mtime, function(err) {
  expect_ok('futimes', fd, err, atime, mtime);

  fs.futimes(-1, atime, mtime, function(err) {
    expect_errno('futimes', -1, err, 'EBADF');
    syncTests();
    callback();
  });
fork icon0
star icon0
watch icon0