@@ -1066,9 +1066,8 @@ void Access(const FunctionCallbackInfo<Value>& args) { |
1066 | 1066 | CHECK_NOT_NULL(*path); |
1067 | 1067 | ToNamespacedPath(env, &path); |
1068 | 1068 |
|
1069 | | - if (argc > 2) { // access(path, mode, req) |
1070 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 2); |
1071 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1069 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 2); |
| 1070 | + if (req_wrap_async != nullptr) { // access(path, mode, req) |
1072 | 1071 | ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( |
1073 | 1072 | env, |
1074 | 1073 | req_wrap_async, |
@@ -1107,9 +1106,8 @@ void Close(const FunctionCallbackInfo<Value>& args) { |
1107 | 1106 | } |
1108 | 1107 | env->RemoveUnmanagedFd(fd); |
1109 | 1108 |
|
1110 | | - if (argc > 1) { // close(fd, req) |
1111 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 1); |
1112 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1109 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 1); |
| 1110 | + if (req_wrap_async != nullptr) { // close(fd, req) |
1113 | 1111 | FS_ASYNC_TRACE_BEGIN0(UV_FS_CLOSE, req_wrap_async) |
1114 | 1112 | AsyncCall( |
1115 | 1113 | env, req_wrap_async, args, "close", UTF8, AfterNoArgs, uv_fs_close, fd); |
@@ -1421,9 +1419,8 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) { |
1421 | 1419 | CHECK(args[2]->IsInt32()); |
1422 | 1420 | int flags = args[2].As<Int32>()->Value(); |
1423 | 1421 |
|
1424 | | - if (argc > 3) { // symlink(target, path, flags, req) |
1425 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
1426 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1422 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 1423 | + if (req_wrap_async != nullptr) { // symlink(target, path, flags, req) |
1427 | 1424 | FS_ASYNC_TRACE_BEGIN2(UV_FS_SYMLINK, |
1428 | 1425 | req_wrap_async, |
1429 | 1426 | "target", |
@@ -1529,9 +1526,8 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) { |
1529 | 1526 |
|
1530 | 1527 | const enum encoding encoding = ParseEncoding(isolate, args[1], UTF8); |
1531 | 1528 |
|
1532 | | - if (argc > 2) { // readlink(path, encoding, req) |
1533 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 2); |
1534 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1529 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 2); |
| 1530 | + if (req_wrap_async != nullptr) { // readlink(path, encoding, req) |
1535 | 1531 | FS_ASYNC_TRACE_BEGIN1( |
1536 | 1532 | UV_FS_READLINK, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
1537 | 1533 | AsyncCall(env, |
@@ -1633,9 +1629,8 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) { |
1633 | 1629 | CHECK(IsSafeJsInt(args[1])); |
1634 | 1630 | const int64_t len = args[1].As<Integer>()->Value(); |
1635 | 1631 |
|
1636 | | - if (argc > 2) { // ftruncate(fd, len, req) |
1637 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 2); |
1638 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1632 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 2); |
| 1633 | + if (req_wrap_async != nullptr) { // ftruncate(fd, len, req) |
1639 | 1634 | FS_ASYNC_TRACE_BEGIN0(UV_FS_FTRUNCATE, req_wrap_async) |
1640 | 1635 | AsyncCall(env, |
1641 | 1636 | req_wrap_async, |
@@ -1665,9 +1660,8 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) { |
1665 | 1660 | return; |
1666 | 1661 | } |
1667 | 1662 |
|
1668 | | - if (argc > 1) { // fdatasync(fd, req) |
1669 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 1); |
1670 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1663 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 1); |
| 1664 | + if (req_wrap_async != nullptr) { // fdatasync(fd, req) |
1671 | 1665 | FS_ASYNC_TRACE_BEGIN0(UV_FS_FDATASYNC, req_wrap_async) |
1672 | 1666 | AsyncCall(env, |
1673 | 1667 | req_wrap_async, |
@@ -1696,9 +1690,8 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) { |
1696 | 1690 | return; |
1697 | 1691 | } |
1698 | 1692 |
|
1699 | | - if (argc > 1) { |
1700 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 1); |
1701 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1693 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 1); |
| 1694 | + if (req_wrap_async != nullptr) { |
1702 | 1695 | FS_ASYNC_TRACE_BEGIN0(UV_FS_FSYNC, req_wrap_async) |
1703 | 1696 | AsyncCall( |
1704 | 1697 | env, req_wrap_async, args, "fsync", UTF8, AfterNoArgs, uv_fs_fsync, fd); |
@@ -1757,9 +1750,8 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) { |
1757 | 1750 | THROW_IF_INSUFFICIENT_PERMISSIONS( |
1758 | 1751 | env, permission::PermissionScope::kFileSystemWrite, path.ToStringView()); |
1759 | 1752 |
|
1760 | | - if (argc > 1) { |
1761 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 1); // rmdir(path, req) |
1762 | | - CHECK_NOT_NULL(req_wrap_async); |
| 1753 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 1); |
| 1754 | + if (req_wrap_async != nullptr) { // rmdir(path, req) |
1763 | 1755 | FS_ASYNC_TRACE_BEGIN1( |
1764 | 1756 | UV_FS_RMDIR, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
1765 | 1757 | AsyncCall(env, |
@@ -2141,9 +2133,8 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) { |
2141 | 2133 | CHECK(args[2]->IsBoolean()); |
2142 | 2134 | bool mkdirp = args[2]->IsTrue(); |
2143 | 2135 |
|
2144 | | - if (argc > 3) { // mkdir(path, mode, recursive, req) |
2145 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
2146 | | - CHECK_NOT_NULL(req_wrap_async); |
| 2136 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 2137 | + if (req_wrap_async != nullptr) { // mkdir(path, mode, recursive, req) |
2147 | 2138 | FS_ASYNC_TRACE_BEGIN1( |
2148 | 2139 | UV_FS_UNLINK, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
2149 | 2140 | AsyncCall(env, |
@@ -2771,9 +2762,9 @@ static void ReadDirRecursive(const FunctionCallbackInfo<Value>& args) { |
2771 | 2762 | // can do those: lib walks the tree in JS when the permission model is on. |
2772 | 2763 | CHECK(!env->permission()->enabled()); |
2773 | 2764 |
|
2774 | | - if (argc > 3) { // readdirRecursive(path, encoding, withTypes, req) |
2775 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
2776 | | - CHECK_NOT_NULL(req_wrap_async); |
| 2765 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 2766 | + if (req_wrap_async != |
| 2767 | + nullptr) { // readdirRecursive(path, encoding, withTypes, req) |
2777 | 2768 | req_wrap_async->Init("scandir", nullptr, 0, encoding); |
2778 | 2769 | FS_ASYNC_TRACE_BEGIN1( |
2779 | 2770 | UV_FS_SCANDIR, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
@@ -2886,9 +2877,8 @@ static void Open(const FunctionCallbackInfo<Value>& args) { |
2886 | 2877 | CHECK(args[2]->IsInt32()); |
2887 | 2878 | const int mode = args[2].As<Int32>()->Value(); |
2888 | 2879 |
|
2889 | | - if (argc > 3) { // open(path, flags, mode, req) |
2890 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
2891 | | - CHECK_NOT_NULL(req_wrap_async); |
| 2880 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 2881 | + if (req_wrap_async != nullptr) { // open(path, flags, mode, req) |
2892 | 2882 | if (AsyncCheckOpenPermissions(env, req_wrap_async, path, flags).IsNothing()) |
2893 | 2883 | return; |
2894 | 2884 | req_wrap_async->set_is_plain_open(true); |
@@ -3148,9 +3138,8 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) { |
3148 | 3138 | iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk)); |
3149 | 3139 | } |
3150 | 3140 |
|
3151 | | - if (argc > 3) { // writeBuffers(fd, chunks, pos, req) |
3152 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
3153 | | - CHECK_NOT_NULL(req_wrap_async); |
| 3141 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 3142 | + if (req_wrap_async != nullptr) { // writeBuffers(fd, chunks, pos, req) |
3154 | 3143 | FS_ASYNC_TRACE_BEGIN0(UV_FS_WRITE, req_wrap_async) |
3155 | 3144 | AsyncCall(env, |
3156 | 3145 | req_wrap_async, |
@@ -3406,9 +3395,8 @@ static void Read(const FunctionCallbackInfo<Value>& args) { |
3406 | 3395 | char* buf = buffer_data + off; |
3407 | 3396 | uv_buf_t uvbuf = uv_buf_init(buf, len); |
3408 | 3397 |
|
3409 | | - if (argc > 5) { // read(fd, buffer, offset, len, pos, req) |
3410 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 5); |
3411 | | - CHECK_NOT_NULL(req_wrap_async); |
| 3398 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 5); |
| 3399 | + if (req_wrap_async != nullptr) { // read(fd, buffer, offset, len, pos, req) |
3412 | 3400 | FS_ASYNC_TRACE_BEGIN0(UV_FS_READ, req_wrap_async) |
3413 | 3401 | AsyncCall(env, |
3414 | 3402 | req_wrap_async, |
@@ -4038,9 +4026,8 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) { |
4038 | 4026 | iovs[i] = uv_buf_init(Buffer::Data(buffer), Buffer::Length(buffer)); |
4039 | 4027 | } |
4040 | 4028 |
|
4041 | | - if (argc > 3) { // readBuffers(fd, buffers, pos, req) |
4042 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
4043 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4029 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 4030 | + if (req_wrap_async != nullptr) { // readBuffers(fd, buffers, pos, req) |
4044 | 4031 | FS_ASYNC_TRACE_BEGIN0(UV_FS_READ, req_wrap_async) |
4045 | 4032 | AsyncCall(env, |
4046 | 4033 | req_wrap_async, |
@@ -4084,9 +4071,8 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) { |
4084 | 4071 | CHECK(args[1]->IsInt32()); |
4085 | 4072 | int mode = args[1].As<Int32>()->Value(); |
4086 | 4073 |
|
4087 | | - if (argc > 2) { // chmod(path, mode, req) |
4088 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 2); |
4089 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4074 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 2); |
| 4075 | + if (req_wrap_async != nullptr) { // chmod(path, mode, req) |
4090 | 4076 | FS_ASYNC_TRACE_BEGIN1( |
4091 | 4077 | UV_FS_CHMOD, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
4092 | 4078 | AsyncCall(env, |
@@ -4123,9 +4109,8 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) { |
4123 | 4109 | CHECK(args[1]->IsInt32()); |
4124 | 4110 | const int mode = args[1].As<Int32>()->Value(); |
4125 | 4111 |
|
4126 | | - if (argc > 2) { // fchmod(fd, mode, req) |
4127 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 2); |
4128 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4112 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 2); |
| 4113 | + if (req_wrap_async != nullptr) { // fchmod(fd, mode, req) |
4129 | 4114 | FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHMOD, req_wrap_async) |
4130 | 4115 | AsyncCall(env, |
4131 | 4116 | req_wrap_async, |
@@ -4210,9 +4195,8 @@ static void FChown(const FunctionCallbackInfo<Value>& args) { |
4210 | 4195 | CHECK(IsSafeJsInt(args[2])); |
4211 | 4196 | const auto gid = FromV8Value<uv_gid_t, true>(args[2]); |
4212 | 4197 |
|
4213 | | - if (argc > 3) { // fchown(fd, uid, gid, req) |
4214 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
4215 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4198 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 4199 | + if (req_wrap_async != nullptr) { // fchown(fd, uid, gid, req) |
4216 | 4200 | FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHOWN, req_wrap_async) |
4217 | 4201 | AsyncCall(env, |
4218 | 4202 | req_wrap_async, |
@@ -4293,9 +4277,8 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) { |
4293 | 4277 | CHECK(args[2]->IsNumber()); |
4294 | 4278 | const double mtime = args[2].As<Number>()->Value(); |
4295 | 4279 |
|
4296 | | - if (argc > 3) { // utimes(path, atime, mtime, req) |
4297 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
4298 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4280 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 4281 | + if (req_wrap_async != nullptr) { // utimes(path, atime, mtime, req) |
4299 | 4282 | FS_ASYNC_TRACE_BEGIN1( |
4300 | 4283 | UV_FS_UTIME, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
4301 | 4284 | AsyncCall(env, |
@@ -4334,9 +4317,8 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) { |
4334 | 4317 | CHECK(args[2]->IsNumber()); |
4335 | 4318 | const double mtime = args[2].As<Number>()->Value(); |
4336 | 4319 |
|
4337 | | - if (argc > 3) { // futimes(fd, atime, mtime, req) |
4338 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
4339 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4320 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 4321 | + if (req_wrap_async != nullptr) { // futimes(fd, atime, mtime, req) |
4340 | 4322 | FS_ASYNC_TRACE_BEGIN0(UV_FS_FUTIME, req_wrap_async) |
4341 | 4323 | AsyncCall(env, |
4342 | 4324 | req_wrap_async, |
@@ -4375,9 +4357,8 @@ static void LUTimes(const FunctionCallbackInfo<Value>& args) { |
4375 | 4357 | CHECK(args[2]->IsNumber()); |
4376 | 4358 | const double mtime = args[2].As<Number>()->Value(); |
4377 | 4359 |
|
4378 | | - if (argc > 3) { // lutimes(path, atime, mtime, req) |
4379 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); |
4380 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4360 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 3); |
| 4361 | + if (req_wrap_async != nullptr) { // lutimes(path, atime, mtime, req) |
4381 | 4362 | FS_ASYNC_TRACE_BEGIN1( |
4382 | 4363 | UV_FS_LUTIME, req_wrap_async, "path", TRACE_STR_COPY(*path)) |
4383 | 4364 | AsyncCall(env, |
@@ -4474,9 +4455,8 @@ static void Mkstemp(const FunctionCallbackInfo<Value>& args) { |
4474 | 4455 |
|
4475 | 4456 | const enum encoding encoding = ParseEncoding(isolate, args[1], UTF8); |
4476 | 4457 |
|
4477 | | - if (argc > 2) { // mkstemp(tmpl, encoding, req) |
4478 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 2); |
4479 | | - CHECK_NOT_NULL(req_wrap_async); |
| 4458 | + FSReqBase* req_wrap_async = GetAsyncReqWrap(args, 2); |
| 4459 | + if (req_wrap_async != nullptr) { // mkstemp(tmpl, encoding, req) |
4480 | 4460 | if (AsyncCheckOpenPermissions(env, req_wrap_async, tmpl, kMkstempFlags) |
4481 | 4461 | .IsNothing()) { |
4482 | 4462 | return; |
|