Description of the fs. chown method in node. js, node. jsfs. chown
Method description:
Change File Ownership.
Syntax:
Copy codeThe Code is as follows:
Fs. chown (path, 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:
Path directory path
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.chown('content.txt ', uid, gid, function (err ){
If (err ){
Console. log (err );
} Else {
Console. log ("change done ");
}
})
Source code:
Copy codeThe Code is as follows:
Fs. chown = function (path, uid, gid, callback ){
Callback = makeCallback (callback );
If (! NullCheck (path, callback) return;
Binding. chown (pathModule. _ makeLong (path), uid, gid, callback );
};