How to use the futimesSync function from fs

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

52
53
54
55
56
57
58
59
60
61
exports.fsync = co.promisify(fs.fsync);
exports.fsyncSync = fs.fsyncSync;
exports.ftruncate = co.promisify(fs.ftruncate);
exports.ftruncateSync = fs.ftruncateSync;
exports.futimes = co.promisify(fs.futimes);
exports.futimesSync = fs.futimesSync;
exports.lchmod = co.promisify(fs.lchmod);
exports.lchmodSync = fs.lchmodSync;
exports.lchown = co.promisify(fs.lchown);
exports.lchownSync = fs.lchownSync;
fork icon22
star icon45
watch icon26

135
136
137
138
139
140
141
142
143
144
expect_ok('lutimesSync', lpath, undefined, atime, mtime, fs.lstatSync);

// Some systems don't have futimes
// if there's an error, it should be ENOSYS
try {
  fs.futimesSync(fd, atime, mtime);
  expect_ok('futimesSync', fd, undefined, atime, mtime);
} catch (ex) {
  expect_errno('futimesSync', fd, ex, 'ENOSYS');
}
fork icon42
star icon19
watch icon0

+ 5 other calls in file

841
842
843
844
845
846
847
848
849
850
851
852


  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

758
759
760
761
762
763
764
765
766
767
// if either fails, handle the first error
if (entry.mtime && !this.noMtime) {
  const atime = entry.atime || new Date()
  const mtime = entry.mtime
  try {
    fs.futimesSync(fd, atime, mtime)
  } catch (futimeser) {
    try {
      fs.utimesSync(entry.absolute, atime, mtime)
    } catch (utimeser) {
fork icon3
star icon2
watch icon0

98
99
100
101
102
103
104
105
106
107
expect_errno('utimesSync', 'foobarbaz', err, 'ENOENT');
tests_run++;

err = undefined;
try {
  fs.futimesSync(-1, atime, mtime);
} catch (ex) {
  err = ex;
}
expect_errno('futimesSync', -1, err, 'EBADF');
fork icon0
star icon0
watch icon0