diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-19 17:09:41 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-27 20:34:02 +0800 |
commit | 437c75649335a0b412670b82d3dfc37be7b01d0b (patch) | |
tree | 212c8ee5af23b6968745f93b90550deeaef8662f /src/node_file.cc | |
parent | e8ec898a7d8169bed73378b5cd4e677adbec16c8 (diff) | |
download | android-node-v8-437c75649335a0b412670b82d3dfc37be7b01d0b.tar.gz android-node-v8-437c75649335a0b412670b82d3dfc37be7b01d0b.tar.bz2 android-node-v8-437c75649335a0b412670b82d3dfc37be7b01d0b.zip |
fs: throw fs.chmodSync errors in JS land
PR-URL: https://github.com/nodejs/node/pull/18871
Refs: https://github.com/nodejs/node/issues/18106
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/node_file.cc')
-rw-r--r-- | src/node_file.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/node_file.cc b/src/node_file.cc index 5e8f9ee168..4e99953b62 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1458,20 +1458,24 @@ static void Read(const FunctionCallbackInfo<Value>& args) { static void Chmod(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - CHECK_GE(args.Length(), 2); - CHECK(args[1]->IsInt32()); + const int argc = args.Length(); + CHECK_GE(argc, 2); BufferValue path(env->isolate(), args[0]); CHECK_NE(*path, nullptr); - int mode = static_cast<int>(args[1]->Int32Value()); + CHECK(args[1]->IsInt32()); + int mode = args[1].As<Int32>()->Value(); FSReqBase* req_wrap = GetReqWrap(env, args[2]); - if (req_wrap != nullptr) { + if (req_wrap != nullptr) { // chmod(path, mode, req) AsyncCall(env, req_wrap, args, "chmod", UTF8, AfterNoArgs, uv_fs_chmod, *path, mode); - } else { - SYNC_CALL(chmod, *path, *path, mode); + } else { // chmod(path, mode, undefined, ctx) + CHECK_EQ(argc, 4); + fs_req_wrap req_wrap; + SyncCall(env, args[3], &req_wrap, "chmod", + uv_fs_chmod, *path, mode); } } |