@@ -676,16 +676,16 @@ void AfterScanDir(uv_fs_t* req) {
676
676
}
677
677
678
678
679
- // This struct is only used on sync fs calls.
679
+ // This class is only used on sync fs calls.
680
680
// For async calls FSReqWrap is used.
681
- class fs_req_wrap {
681
+ class FSReqWrapSync {
682
682
public:
683
- fs_req_wrap () {}
684
- ~fs_req_wrap () { uv_fs_req_cleanup (&req); }
683
+ FSReqWrapSync () {}
684
+ ~FSReqWrapSync () { uv_fs_req_cleanup (&req); }
685
685
uv_fs_t req;
686
686
687
687
private:
688
- DISALLOW_COPY_AND_ASSIGN (fs_req_wrap );
688
+ DISALLOW_COPY_AND_ASSIGN (FSReqWrapSync );
689
689
};
690
690
691
691
// Returns nullptr if the operation fails from the start.
@@ -729,7 +729,7 @@ inline FSReqBase* AsyncCall(Environment* env,
729
729
// creating an error in the C++ land.
730
730
// ctx must be checked using value->IsObject() before being passed.
731
731
template <typename Func, typename ... Args>
732
- inline int SyncCall (Environment* env, Local<Value> ctx, fs_req_wrap * req_wrap,
732
+ inline int SyncCall (Environment* env, Local<Value> ctx, FSReqWrapSync * req_wrap,
733
733
const char * syscall, Func fn, Args... args) {
734
734
env->PrintSyncTrace ();
735
735
int err = fn (env->event_loop (), &(req_wrap->req ), args..., nullptr );
@@ -775,7 +775,7 @@ void Access(const FunctionCallbackInfo<Value>& args) {
775
775
uv_fs_access, *path, mode);
776
776
} else { // access(path, mode, undefined, ctx)
777
777
CHECK_EQ (argc, 4 );
778
- fs_req_wrap req_wrap;
778
+ FSReqWrapSync req_wrap;
779
779
SyncCall (env, args[3 ], &req_wrap, " access" , uv_fs_access, *path, mode);
780
780
}
781
781
}
@@ -796,7 +796,7 @@ void Close(const FunctionCallbackInfo<Value>& args) {
796
796
uv_fs_close, fd);
797
797
} else { // close(fd, undefined, ctx)
798
798
CHECK_EQ (argc, 3 );
799
- fs_req_wrap req_wrap;
799
+ FSReqWrapSync req_wrap;
800
800
SyncCall (env, args[2 ], &req_wrap, " close" , uv_fs_close, fd);
801
801
}
802
802
}
@@ -904,7 +904,7 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
904
904
uv_fs_stat, *path);
905
905
} else { // stat(path, undefined, ctx)
906
906
CHECK_EQ (argc, 3 );
907
- fs_req_wrap req_wrap;
907
+ FSReqWrapSync req_wrap;
908
908
int err = SyncCall (env, args[2 ], &req_wrap, " stat" , uv_fs_stat, *path);
909
909
if (err == 0 ) {
910
910
FillStatsArray (env->fs_stats_field_array (),
@@ -928,7 +928,7 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
928
928
uv_fs_lstat, *path);
929
929
} else { // lstat(path, undefined, ctx)
930
930
CHECK_EQ (argc, 3 );
931
- fs_req_wrap req_wrap;
931
+ FSReqWrapSync req_wrap;
932
932
int err = SyncCall (env, args[2 ], &req_wrap, " lstat" , uv_fs_lstat, *path);
933
933
if (err == 0 ) {
934
934
FillStatsArray (env->fs_stats_field_array (),
@@ -952,7 +952,7 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
952
952
uv_fs_fstat, fd);
953
953
} else { // fstat(fd, undefined, ctx)
954
954
CHECK_EQ (argc, 3 );
955
- fs_req_wrap req_wrap;
955
+ FSReqWrapSync req_wrap;
956
956
int err = SyncCall (env, args[2 ], &req_wrap, " fstat" , uv_fs_fstat, fd);
957
957
if (err == 0 ) {
958
958
FillStatsArray (env->fs_stats_field_array (),
@@ -981,7 +981,7 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
981
981
AfterNoArgs, uv_fs_symlink, *target, *path, flags);
982
982
} else { // symlink(target, path, flags, undefinec, ctx)
983
983
CHECK_EQ (argc, 5 );
984
- fs_req_wrap req;
984
+ FSReqWrapSync req;
985
985
SyncCall (env, args[4 ], &req, " symlink" ,
986
986
uv_fs_symlink, *target, *path, flags);
987
987
}
@@ -1005,7 +1005,7 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
1005
1005
AfterNoArgs, uv_fs_link, *src, *dest);
1006
1006
} else { // link(src, dest)
1007
1007
CHECK_EQ (argc, 4 );
1008
- fs_req_wrap req;
1008
+ FSReqWrapSync req;
1009
1009
SyncCall (env, args[3 ], &req, " link" ,
1010
1010
uv_fs_link, *src, *dest);
1011
1011
}
@@ -1028,7 +1028,7 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
1028
1028
uv_fs_readlink, *path);
1029
1029
} else {
1030
1030
CHECK_EQ (argc, 4 );
1031
- fs_req_wrap req;
1031
+ FSReqWrapSync req;
1032
1032
int err = SyncCall (env, args[3 ], &req, " readlink" ,
1033
1033
uv_fs_readlink, *path);
1034
1034
if (err < 0 ) {
@@ -1068,7 +1068,7 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
1068
1068
UTF8, AfterNoArgs, uv_fs_rename, *old_path, *new_path);
1069
1069
} else {
1070
1070
CHECK_EQ (argc, 4 );
1071
- fs_req_wrap req;
1071
+ FSReqWrapSync req;
1072
1072
SyncCall (env, args[3 ], &req, " rename" , uv_fs_rename, *old_path, *new_path);
1073
1073
}
1074
1074
}
@@ -1091,7 +1091,7 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
1091
1091
uv_fs_ftruncate, fd, len);
1092
1092
} else {
1093
1093
CHECK_EQ (argc, 4 );
1094
- fs_req_wrap req;
1094
+ FSReqWrapSync req;
1095
1095
SyncCall (env, args[3 ], &req, " ftruncate" , uv_fs_ftruncate, fd, len);
1096
1096
}
1097
1097
}
@@ -1111,7 +1111,7 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) {
1111
1111
uv_fs_fdatasync, fd);
1112
1112
} else {
1113
1113
CHECK_EQ (argc, 3 );
1114
- fs_req_wrap req;
1114
+ FSReqWrapSync req;
1115
1115
SyncCall (env, args[2 ], &req, " fdatasync" , uv_fs_fdatasync, fd);
1116
1116
}
1117
1117
}
@@ -1131,7 +1131,7 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) {
1131
1131
uv_fs_fsync, fd);
1132
1132
} else {
1133
1133
CHECK_EQ (argc, 3 );
1134
- fs_req_wrap req;
1134
+ FSReqWrapSync req;
1135
1135
SyncCall (env, args[2 ], &req, " fsync" , uv_fs_fsync, fd);
1136
1136
}
1137
1137
}
@@ -1151,7 +1151,7 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
1151
1151
uv_fs_unlink, *path);
1152
1152
} else {
1153
1153
CHECK_EQ (argc, 3 );
1154
- fs_req_wrap req;
1154
+ FSReqWrapSync req;
1155
1155
SyncCall (env, args[2 ], &req, " unlink" , uv_fs_unlink, *path);
1156
1156
}
1157
1157
}
@@ -1171,7 +1171,7 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
1171
1171
uv_fs_rmdir, *path);
1172
1172
} else { // rmdir(path, undefined, ctx)
1173
1173
CHECK_EQ (argc, 3 );
1174
- fs_req_wrap req_wrap;
1174
+ FSReqWrapSync req_wrap;
1175
1175
SyncCall (env, args[2 ], &req_wrap, " rmdir" ,
1176
1176
uv_fs_rmdir, *path);
1177
1177
}
@@ -1195,7 +1195,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
1195
1195
uv_fs_mkdir, *path, mode);
1196
1196
} else { // mkdir(path, mode, undefined, ctx)
1197
1197
CHECK_EQ (argc, 4 );
1198
- fs_req_wrap req_wrap;
1198
+ FSReqWrapSync req_wrap;
1199
1199
SyncCall (env, args[3 ], &req_wrap, " mkdir" ,
1200
1200
uv_fs_mkdir, *path, mode);
1201
1201
}
@@ -1218,7 +1218,7 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
1218
1218
uv_fs_realpath, *path);
1219
1219
} else { // realpath(path, encoding, undefined, ctx)
1220
1220
CHECK_EQ (argc, 4 );
1221
- fs_req_wrap req_wrap;
1221
+ FSReqWrapSync req_wrap;
1222
1222
int err = SyncCall (env, args[3 ], &req_wrap, " realpath" ,
1223
1223
uv_fs_realpath, *path);
1224
1224
if (err < 0 ) {
@@ -1259,7 +1259,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
1259
1259
uv_fs_scandir, *path, 0 /* flags*/ );
1260
1260
} else { // readdir(path, encoding, undefined, ctx)
1261
1261
CHECK_EQ (argc, 4 );
1262
- fs_req_wrap req_wrap;
1262
+ FSReqWrapSync req_wrap;
1263
1263
int err = SyncCall (env, args[3 ], &req_wrap, " scandir" ,
1264
1264
uv_fs_scandir, *path, 0 /* flags*/ );
1265
1265
if (err < 0 ) {
@@ -1343,7 +1343,7 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
1343
1343
uv_fs_open, *path, flags, mode);
1344
1344
} else { // open(path, flags, mode, undefined, ctx)
1345
1345
CHECK_EQ (argc, 5 );
1346
- fs_req_wrap req_wrap;
1346
+ FSReqWrapSync req_wrap;
1347
1347
int result = SyncCall (env, args[4 ], &req_wrap, " open" ,
1348
1348
uv_fs_open, *path, flags, mode);
1349
1349
args.GetReturnValue ().Set (result);
@@ -1371,7 +1371,7 @@ static void OpenFileHandle(const FunctionCallbackInfo<Value>& args) {
1371
1371
uv_fs_open, *path, flags, mode);
1372
1372
} else { // openFileHandle(path, flags, mode, undefined, ctx)
1373
1373
CHECK_EQ (argc, 5 );
1374
- fs_req_wrap req_wrap;
1374
+ FSReqWrapSync req_wrap;
1375
1375
int result = SyncCall (env, args[4 ], &req_wrap, " open" ,
1376
1376
uv_fs_open, *path, flags, mode);
1377
1377
if (result < 0 ) {
@@ -1405,7 +1405,7 @@ static void CopyFile(const FunctionCallbackInfo<Value>& args) {
1405
1405
uv_fs_copyfile, *src, *dest, flags);
1406
1406
} else { // copyFile(src, dest, flags, undefined, ctx)
1407
1407
CHECK_EQ (argc, 5 );
1408
- fs_req_wrap req_wrap;
1408
+ FSReqWrapSync req_wrap;
1409
1409
SyncCall (env, args[4 ], &req_wrap, " copyfile" ,
1410
1410
uv_fs_copyfile, *src, *dest, flags);
1411
1411
}
@@ -1456,7 +1456,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
1456
1456
uv_fs_write, fd, &uvbuf, 1 , pos);
1457
1457
} else { // write(fd, buffer, off, len, pos, undefined, ctx)
1458
1458
CHECK_EQ (argc, 7 );
1459
- fs_req_wrap req_wrap;
1459
+ FSReqWrapSync req_wrap;
1460
1460
int bytesWritten = SyncCall (env, args[6 ], &req_wrap, " write" ,
1461
1461
uv_fs_write, fd, &uvbuf, 1 , pos);
1462
1462
args.GetReturnValue ().Set (bytesWritten);
@@ -1499,7 +1499,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
1499
1499
uv_fs_write, fd, *iovs, iovs.length (), pos);
1500
1500
} else { // writeBuffers(fd, chunks, pos, undefined, ctx)
1501
1501
CHECK_EQ (argc, 5 );
1502
- fs_req_wrap req_wrap;
1502
+ FSReqWrapSync req_wrap;
1503
1503
int bytesWritten = SyncCall (env, args[4 ], &req_wrap, " write" ,
1504
1504
uv_fs_write, fd, *iovs, iovs.length (), pos);
1505
1505
args.GetReturnValue ().Set (bytesWritten);
@@ -1578,7 +1578,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
1578
1578
}
1579
1579
} else { // write(fd, string, pos, enc, undefined, ctx)
1580
1580
CHECK_EQ (argc, 6 );
1581
- fs_req_wrap req_wrap;
1581
+ FSReqWrapSync req_wrap;
1582
1582
FSReqBase::FSReqBuffer stack_buffer;
1583
1583
if (buf == nullptr ) {
1584
1584
len = StringBytes::StorageSize (env->isolate (), value, enc);
@@ -1643,7 +1643,7 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
1643
1643
uv_fs_read, fd, &uvbuf, 1 , pos);
1644
1644
} else { // read(fd, buffer, offset, len, pos, undefined, ctx)
1645
1645
CHECK_EQ (argc, 7 );
1646
- fs_req_wrap req_wrap;
1646
+ FSReqWrapSync req_wrap;
1647
1647
const int bytesRead = SyncCall (env, args[6 ], &req_wrap, " read" ,
1648
1648
uv_fs_read, fd, &uvbuf, 1 , pos);
1649
1649
args.GetReturnValue ().Set (bytesRead);
@@ -1672,7 +1672,7 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
1672
1672
uv_fs_chmod, *path, mode);
1673
1673
} else { // chmod(path, mode, undefined, ctx)
1674
1674
CHECK_EQ (argc, 4 );
1675
- fs_req_wrap req_wrap;
1675
+ FSReqWrapSync req_wrap;
1676
1676
SyncCall (env, args[3 ], &req_wrap, " chmod" ,
1677
1677
uv_fs_chmod, *path, mode);
1678
1678
}
@@ -1700,7 +1700,7 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
1700
1700
uv_fs_fchmod, fd, mode);
1701
1701
} else { // fchmod(fd, mode, undefined, ctx)
1702
1702
CHECK_EQ (argc, 4 );
1703
- fs_req_wrap req_wrap;
1703
+ FSReqWrapSync req_wrap;
1704
1704
SyncCall (env, args[3 ], &req_wrap, " fchmod" ,
1705
1705
uv_fs_fchmod, fd, mode);
1706
1706
}
@@ -1731,7 +1731,7 @@ static void Chown(const FunctionCallbackInfo<Value>& args) {
1731
1731
uv_fs_chown, *path, uid, gid);
1732
1732
} else { // chown(path, uid, gid, undefined, ctx)
1733
1733
CHECK_EQ (argc, 5 );
1734
- fs_req_wrap req_wrap;
1734
+ FSReqWrapSync req_wrap;
1735
1735
SyncCall (env, args[4 ], &req_wrap, " chown" ,
1736
1736
uv_fs_chown, *path, uid, gid);
1737
1737
}
@@ -1762,7 +1762,7 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
1762
1762
uv_fs_fchown, fd, uid, gid);
1763
1763
} else { // fchown(fd, uid, gid, undefined, ctx)
1764
1764
CHECK_EQ (argc, 5 );
1765
- fs_req_wrap req_wrap;
1765
+ FSReqWrapSync req_wrap;
1766
1766
SyncCall (env, args[4 ], &req_wrap, " fchown" ,
1767
1767
uv_fs_fchown, fd, uid, gid);
1768
1768
}
@@ -1790,7 +1790,7 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
1790
1790
uv_fs_utime, *path, atime, mtime);
1791
1791
} else { // utimes(path, atime, mtime, undefined, ctx)
1792
1792
CHECK_EQ (argc, 5 );
1793
- fs_req_wrap req_wrap;
1793
+ FSReqWrapSync req_wrap;
1794
1794
SyncCall (env, args[4 ], &req_wrap, " utime" ,
1795
1795
uv_fs_utime, *path, atime, mtime);
1796
1796
}
@@ -1817,7 +1817,7 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
1817
1817
uv_fs_futime, fd, atime, mtime);
1818
1818
} else { // futimes(fd, atime, mtime, undefined, ctx)
1819
1819
CHECK_EQ (argc, 5 );
1820
- fs_req_wrap req_wrap;
1820
+ FSReqWrapSync req_wrap;
1821
1821
SyncCall (env, args[4 ], &req_wrap, " futime" ,
1822
1822
uv_fs_futime, fd, atime, mtime);
1823
1823
}
@@ -1840,7 +1840,7 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
1840
1840
uv_fs_mkdtemp, *tmpl);
1841
1841
} else { // mkdtemp(tmpl, encoding, undefined, ctx)
1842
1842
CHECK_EQ (argc, 4 );
1843
- fs_req_wrap req_wrap;
1843
+ FSReqWrapSync req_wrap;
1844
1844
SyncCall (env, args[3 ], &req_wrap, " mkdtemp" ,
1845
1845
uv_fs_mkdtemp, *tmpl);
1846
1846
const char * path = static_cast <const char *>(req_wrap.req .path );
0 commit comments