This article mainly introduces node. fs. fchown method usage instructions. This article introduces fs. fchown method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
Change the File Ownership (file descriptor ).
Syntax:
The 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:
The 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:
The Code is as follows:
Fs. fchown = function (fd, uid, gid, callback ){
Binding. fchown (fd, uid, gid, makeCallback (callback ));
};