diff options
author | cjihrig <cjihrig@gmail.com> | 2018-06-23 16:26:29 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-06-27 11:37:17 -0400 |
commit | 7ff50f9e9cf5459c60f10f3919e79223c8b7446c (patch) | |
tree | d6b8221698f8582406f54385bdcd583c21c0ec26 /src | |
parent | 4750ce26f2e6079b5fee92bdee5356c279171d22 (diff) | |
download | android-node-v8-7ff50f9e9cf5459c60f10f3919e79223c8b7446c.tar.gz android-node-v8-7ff50f9e9cf5459c60f10f3919e79223c8b7446c.tar.bz2 android-node-v8-7ff50f9e9cf5459c60f10f3919e79223c8b7446c.zip |
fs: undeprecate lchown()
uv_fs_lchown() exists, as of libuv 1.21.0. fs.lchown() can now
be undeprecated. This commit also adds tests, as there were
none.
PR-URL: https://github.com/nodejs/node/pull/21498
Fixes: https://github.com/nodejs/node/issues/19868
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_file.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/node_file.cc b/src/node_file.cc index a63e90fafb..ed1799da58 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1771,6 +1771,36 @@ static void FChown(const FunctionCallbackInfo<Value>& args) { } +static void LChown(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + + const int argc = args.Length(); + CHECK_GE(argc, 3); + + BufferValue path(env->isolate(), args[0]); + CHECK_NOT_NULL(*path); + + CHECK(args[1]->IsUint32()); + const uv_uid_t uid = static_cast<uv_uid_t>(args[1].As<Uint32>()->Value()); + + CHECK(args[2]->IsUint32()); + const uv_gid_t gid = static_cast<uv_gid_t>(args[2].As<Uint32>()->Value()); + + FSReqBase* req_wrap_async = GetReqWrap(env, args[3]); + if (req_wrap_async != nullptr) { // lchown(path, uid, gid, req) + AsyncCall(env, req_wrap_async, args, "lchown", UTF8, AfterNoArgs, + uv_fs_lchown, *path, uid, gid); + } else { // lchown(path, uid, gid, undefined, ctx) + CHECK_EQ(argc, 5); + FSReqWrapSync req_wrap_sync; + FS_SYNC_TRACE_BEGIN(lchown); + SyncCall(env, args[4], &req_wrap_sync, "lchown", + uv_fs_lchown, *path, uid, gid); + FS_SYNC_TRACE_END(lchown); + } +} + + static void UTimes(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); @@ -1904,7 +1934,7 @@ void Initialize(Local<Object> target, env->SetMethod(target, "chown", Chown); env->SetMethod(target, "fchown", FChown); - // env->SetMethod(target, "lchown", LChown); + env->SetMethod(target, "lchown", LChown); env->SetMethod(target, "utimes", UTimes); env->SetMethod(target, "futimes", FUTimes); |