Description of the fs. fchown method in node. js, node. jsfs. fchown
Method description:
Change the File Ownership (file descriptor ).
Syntax:
Copy codeThe Code is as follows:
Fs. fchown (fd, uid, gid, [callback (err)])
Because this method belongs to the fs module, we need to introduce the fs module (var fs = require ("fs") before use "))
Receiving parameters:
Fd file descriptor
Uid user ID
Gid group identity (the identity of the user of the shared resource system)
Callback, passing the exception parameter err
Example:
Copy codeThe Code 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:
Copy codeThe Code is as follows:
Fs. fchown = function (fd, uid, gid, callback ){
Binding. fchown (fd, uid, gid, makeCallback (callback ));
};