@@ -1458,20 +1458,24 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
1458
1458
static void Chmod (const FunctionCallbackInfo<Value>& args) {
1459
1459
Environment* env = Environment::GetCurrent (args);
1460
1460
1461
- CHECK_GE ( args.Length (), 2 );
1462
- CHECK (args[ 1 ]-> IsInt32 () );
1461
+ const int argc = args.Length ();
1462
+ CHECK_GE (argc, 2 );
1463
1463
1464
1464
BufferValue path (env->isolate (), args[0 ]);
1465
1465
CHECK_NE (*path, nullptr );
1466
1466
1467
- int mode = static_cast <int >(args[1 ]->Int32Value ());
1467
+ CHECK (args[1 ]->IsInt32 ());
1468
+ int mode = args[1 ].As <Int32>()->Value ();
1468
1469
1469
1470
FSReqBase* req_wrap = GetReqWrap (env, args[2 ]);
1470
- if (req_wrap != nullptr ) {
1471
+ if (req_wrap != nullptr ) { // chmod(path, mode, req)
1471
1472
AsyncCall (env, req_wrap, args, " chmod" , UTF8, AfterNoArgs,
1472
1473
uv_fs_chmod, *path, mode);
1473
- } else {
1474
- SYNC_CALL (chmod, *path, *path, mode);
1474
+ } else { // chmod(path, mode, undefined, ctx)
1475
+ CHECK_EQ (argc, 4 );
1476
+ fs_req_wrap req_wrap;
1477
+ SyncCall (env, args[3 ], &req_wrap, " chmod" ,
1478
+ uv_fs_chmod, *path, mode);
1475
1479
}
1476
1480
}
1477
1481
0 commit comments