This article mainly introduces node. fs. chown method usage instructions. This article introduces fs. chown method description, syntax, receiving parameters, use instances and implementation source code. For more information, see
Method description:
Change file ownership.
Syntax:
The 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:
The code is as follows:
Fs.chown('content.txt ', uid, gid, function (err ){
If (err ){
Console. log (err );
} Else {
Console. log ("change done ");
}
})
Source code:
The 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 );
};