Method description:
Change file ownership.
grammar:
The code copy is as follows:
fs.chown(path, 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:
path directory path
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.chown('content.txt', uid, gid, function(err){
if(err){
console.log(err);
}else{
console.log("change done");
}
})
Source code:
The code copy 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);
};