This article mainly introduces node. fs. the lchmod method is described in this article. lchmod method description, syntax, receiving parameters, use instances and implementation source code. For more information, see
Method description:
Change file permissions (do not parse symbolic links ).
Syntax:
The Code is as follows:
Fs. lchmod (fd, mode, [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
Mode File Permission
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. lchmod (fd, 0777, 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. lchmod = function (path, mode, callback ){
Callback = maybeCallback (callback );
Fs. open (path, constants. O_WRONLY | constants. O_SYMLINK, function (err, fd ){
If (err ){
Callback (err );
Return;
}
// Prefer to return the chmod error, if one occurs,
// But still try to close, and report closing errors if they occur.
Fs. fchmod (fd, mode, function (err ){
Fs. close (fd, function (err2 ){
Callback (err | err2 );
});
});
});
};