Method description:
Change file ownership (file descriptor).
grammar:
The code copy is as follows:
fs.fchown(fd, uid, gid, [callback(err)])
Since this method belongs to the fs module, it is necessary to introduce the fs module before use (var fs= require("fs") )
Receive parameters:
fd file descriptor
uid user ID
gid group identity (refers to the identity of the user of the shared resource system)
callback callback, passing exception parameter err
example:
The code copy is as follows:
fs.open('content.txt', 'a', function (err, fd) {
if (err) {
throw err;
}
fs.fchown(fd, uid, gid, function(err){
if (err) {
throw err;
}
console.log('fchmod complete');
fs.close(fd, function () {
console.log('Done');
});
})
});
Source code:
The code copy is as follows:
fs.fchown = function(fd, uid, gid, callback) {
binding.fchown(fd, uid, gid, makeCallback(callback));
};