How to use the fstat function from fs

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

115
116
117
118
119
120
121
122
123
124
  assert.strictEqual(err.syscall, 'fstat');
  return true;
};

common.runWithInvalidFD((fd) => {
  fs.fstat(fd, common.mustCall(validateError));

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

27
28
29
30
31
32
33
34
35
36
37
38
39
const fs = require('fs');


const dataExpected = fs.readFileSync(__filename, 'utf8');


// sometimes stat returns size=0, but it's a lie.
fs._fstat = fs.fstat;
fs._fstatSync = fs.fstatSync;


fs.fstat = (fd, cb) => {
  fs._fstat(fd, (er, st) => {
fork icon0
star icon1
watch icon0

184
185
186
187
188
189
190
191
192

if (er) {
  return reject(er)
}

fs.fstat(fd, (er, st) => {
  if (er) {
    return fs.close(fd, () => reject(er))
  }
fork icon0
star icon0
watch icon0

50
51
52
53
54
55
56
57
58
59
60
// fstat
fs.open('.', 'r', undefined, function(err, fd) {
  assert.ok(!err);
  assert.ok(fd);


  fs.fstat(fd, function(err, stats) {
    if (err) {
      got_error = true;
    } else {
      console.dir(stats);
fork icon0
star icon0
watch icon0