GH-853 fs.lchown and fs.lchmod
This commit is contained in:
Родитель
5cfac21852
Коммит
3935adced0
37
lib/fs.js
37
lib/fs.js
|
@ -440,6 +440,25 @@ fs.fchmodSync = function(fd, mode) {
|
|||
return binding.fchmod(fd, modeNum(mode));
|
||||
};
|
||||
|
||||
if (constants.hasOwnProperty('O_SYMLINK')) {
|
||||
fs.lchmod = function(path, mode, callback) {
|
||||
callback = callback || noop;
|
||||
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function (err, fd) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
fs.fchmod(fd, mode, callback);
|
||||
});
|
||||
};
|
||||
|
||||
fs.lchmodSync = function(path, mode) {
|
||||
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
|
||||
return fs.fchmodSync(fd, mode);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
fs.chmod = function(path, mode, callback) {
|
||||
binding.chmod(path, modeNum(mode), callback || noop);
|
||||
};
|
||||
|
@ -448,6 +467,24 @@ fs.chmodSync = function(path, mode) {
|
|||
return binding.chmod(path, modeNum(mode));
|
||||
};
|
||||
|
||||
if (constants.hasOwnProperty('O_SYMLINK')) {
|
||||
fs.lchown = function(path, uid, gid, callback) {
|
||||
callback = callback || noop;
|
||||
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function (err, fd) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
fs.fchown(fd, uid, gid, callback);
|
||||
});
|
||||
};
|
||||
|
||||
fs.lchownSync = function(path, uid, gid) {
|
||||
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
|
||||
return fs.fchownSync(fd, uid, gid);
|
||||
};
|
||||
}
|
||||
|
||||
fs.fchown = function(fd, uid, gid, callback) {
|
||||
binding.fchown(fd, uid, gid, callback || noop);
|
||||
};
|
||||
|
|
|
@ -103,6 +103,11 @@ void DefineConstants(Handle<Object> target) {
|
|||
NODE_DEFINE_CONSTANT(target, O_SYNC);
|
||||
#endif
|
||||
|
||||
#ifdef O_SYMLINK
|
||||
NODE_DEFINE_CONSTANT(target, O_SYMLINK);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef S_IRWXU
|
||||
NODE_DEFINE_CONSTANT(target, S_IRWXU);
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче