How to use the fchown function from fs

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

775
776
777
778
779
780
781
782
783
784
  assert.strictEqual(err.syscall, 'fchown');
  return true;
};

common.runWithInvalidFD((fd) => {
  fs.fchown(fd, process.getuid(), process.getgid(),
            common.mustCall(validateError));

  assert.throws(
    () => fs.fchownSync(fd, process.getuid(), process.getgid()),
fork icon42
star icon19
watch icon0

420
421
422
423
424
425
426
427
428

if (this[DOCHOWN](entry)) {
  actions++
  const uid = this[UID](entry)
  const gid = this[GID](entry)
  fs.fchown(fd, uid, gid, er =>
    er ? fs.chown(abs, uid, gid, er2 => done(er2 && er))
    : done())
}
fork icon3
star icon2
watch icon0

70
71
72
73
74
75
76
77
78
79
80


function fchown({ uid, gid }) {
  const fs = require('fs');
  fs.writeFileSync('fs6.txt', '123', 'utf8');
  const fd = fs.openSync('fs6.txt', 'r+');
  fs.fchown(fd, uid, gid, () => {
    fs.unlinkSync('fs6.txt');
  });
}

fork icon0
star icon0
watch icon0

+ 2 other calls in file