Skip to content

Commit 172b4d7

Browse files
committed
src,lib: rename FSReqWrap to FSReqCallback
Given that FSReqPromise does not inherit from FSReqWrap, FSReqWrap should be renamed FSReqCallback to better describe what it does. First of a few upcoming `fs` refactorings :) PR-URL: #21971 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 27a5338 commit 172b4d7

File tree

6 files changed

+55
-55
lines changed

6 files changed

+55
-55
lines changed

lib/fs.js

+33-33
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const {
5252
ERR_INVALID_CALLBACK
5353
} = errors.codes;
5454

55-
const { FSReqWrap, statValues } = binding;
55+
const { FSReqCallback, statValues } = binding;
5656
const internalFS = require('internal/fs/utils');
5757
const { getPathFromURL } = require('internal/url');
5858
const internalUtil = require('internal/util');
@@ -179,7 +179,7 @@ function access(path, mode, callback) {
179179
validatePath(path);
180180

181181
mode = mode | 0;
182-
const req = new FSReqWrap();
182+
const req = new FSReqCallback();
183183
req.oncomplete = makeCallback(callback);
184184
binding.access(pathModule.toNamespacedPath(path), mode, req);
185185
}
@@ -243,7 +243,7 @@ function readFileAfterOpen(err, fd) {
243243

244244
context.fd = fd;
245245

246-
const req = new FSReqWrap();
246+
const req = new FSReqCallback();
247247
req.oncomplete = readFileAfterStat;
248248
req.context = context;
249249
binding.fstat(fd, false, req);
@@ -284,7 +284,7 @@ function readFile(path, options, callback) {
284284
const context = new ReadFileContext(callback, options.encoding);
285285
context.isUserFd = isFd(path); // file descriptor ownership
286286

287-
const req = new FSReqWrap();
287+
const req = new FSReqCallback();
288288
req.context = context;
289289
req.oncomplete = readFileAfterOpen;
290290

@@ -393,7 +393,7 @@ function readFileSync(path, options) {
393393

394394
function close(fd, callback) {
395395
validateUint32(fd, 'fd');
396-
const req = new FSReqWrap();
396+
const req = new FSReqCallback();
397397
req.oncomplete = makeCallback(callback);
398398
binding.close(fd, req);
399399
}
@@ -418,7 +418,7 @@ function open(path, flags, mode, callback) {
418418
callback = makeCallback(callback);
419419
}
420420

421-
const req = new FSReqWrap();
421+
const req = new FSReqCallback();
422422
req.oncomplete = callback;
423423

424424
binding.open(pathModule.toNamespacedPath(path),
@@ -470,7 +470,7 @@ function read(fd, buffer, offset, length, position, callback) {
470470
callback && callback(err, bytesRead || 0, buffer);
471471
}
472472

473-
const req = new FSReqWrap();
473+
const req = new FSReqCallback();
474474
req.oncomplete = wrapper;
475475

476476
binding.read(fd, buffer, offset, length, position, req);
@@ -519,7 +519,7 @@ function write(fd, buffer, offset, length, position, callback) {
519519

520520
validateUint32(fd, 'fd');
521521

522-
const req = new FSReqWrap();
522+
const req = new FSReqCallback();
523523
req.oncomplete = wrapper;
524524

525525
if (isUint8Array(buffer)) {
@@ -588,7 +588,7 @@ function rename(oldPath, newPath, callback) {
588588
validatePath(oldPath, 'oldPath');
589589
newPath = getPathFromURL(newPath);
590590
validatePath(newPath, 'newPath');
591-
const req = new FSReqWrap();
591+
const req = new FSReqCallback();
592592
req.oncomplete = callback;
593593
binding.rename(pathModule.toNamespacedPath(oldPath),
594594
pathModule.toNamespacedPath(newPath),
@@ -622,7 +622,7 @@ function truncate(path, len, callback) {
622622
callback = maybeCallback(callback);
623623
fs.open(path, 'r+', function(er, fd) {
624624
if (er) return callback(er);
625-
const req = new FSReqWrap();
625+
const req = new FSReqCallback();
626626
req.oncomplete = function oncomplete(er) {
627627
fs.close(fd, function(er2) {
628628
callback(er || er2);
@@ -661,7 +661,7 @@ function ftruncate(fd, len = 0, callback) {
661661
validateUint32(fd, 'fd');
662662
validateInteger(len, 'len');
663663
len = Math.max(0, len);
664-
const req = new FSReqWrap();
664+
const req = new FSReqCallback();
665665
req.oncomplete = makeCallback(callback);
666666
binding.ftruncate(fd, len, req);
667667
}
@@ -679,7 +679,7 @@ function rmdir(path, callback) {
679679
callback = makeCallback(callback);
680680
path = getPathFromURL(path);
681681
validatePath(path);
682-
const req = new FSReqWrap();
682+
const req = new FSReqCallback();
683683
req.oncomplete = callback;
684684
binding.rmdir(pathModule.toNamespacedPath(path), req);
685685
}
@@ -694,7 +694,7 @@ function rmdirSync(path) {
694694

695695
function fdatasync(fd, callback) {
696696
validateUint32(fd, 'fd');
697-
const req = new FSReqWrap();
697+
const req = new FSReqCallback();
698698
req.oncomplete = makeCallback(callback);
699699
binding.fdatasync(fd, req);
700700
}
@@ -708,7 +708,7 @@ function fdatasyncSync(fd) {
708708

709709
function fsync(fd, callback) {
710710
validateUint32(fd, 'fd');
711-
const req = new FSReqWrap();
711+
const req = new FSReqCallback();
712712
req.oncomplete = makeCallback(callback);
713713
binding.fsync(fd, req);
714714
}
@@ -732,7 +732,7 @@ function mkdir(path, mode, callback) {
732732
mode = validateMode(mode, 'mode', 0o777);
733733
}
734734

735-
const req = new FSReqWrap();
735+
const req = new FSReqCallback();
736736
req.oncomplete = callback;
737737
binding.mkdir(pathModule.toNamespacedPath(path), mode, req);
738738
}
@@ -752,7 +752,7 @@ function readdir(path, options, callback) {
752752
path = getPathFromURL(path);
753753
validatePath(path);
754754

755-
const req = new FSReqWrap();
755+
const req = new FSReqCallback();
756756
req.oncomplete = callback;
757757
binding.readdir(pathModule.toNamespacedPath(path), options.encoding, req);
758758
}
@@ -774,7 +774,7 @@ function fstat(fd, options, callback) {
774774
options = {};
775775
}
776776
validateUint32(fd, 'fd');
777-
const req = new FSReqWrap(options.bigint);
777+
const req = new FSReqCallback(options.bigint);
778778
req.oncomplete = makeStatsCallback(callback);
779779
binding.fstat(fd, options.bigint, req);
780780
}
@@ -787,7 +787,7 @@ function lstat(path, options, callback) {
787787
callback = makeStatsCallback(callback);
788788
path = getPathFromURL(path);
789789
validatePath(path);
790-
const req = new FSReqWrap(options.bigint);
790+
const req = new FSReqCallback(options.bigint);
791791
req.oncomplete = callback;
792792
binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req);
793793
}
@@ -800,7 +800,7 @@ function stat(path, options, callback) {
800800
callback = makeStatsCallback(callback);
801801
path = getPathFromURL(path);
802802
validatePath(path);
803-
const req = new FSReqWrap(options.bigint);
803+
const req = new FSReqCallback(options.bigint);
804804
req.oncomplete = callback;
805805
binding.stat(pathModule.toNamespacedPath(path), options.bigint, req);
806806
}
@@ -838,7 +838,7 @@ function readlink(path, options, callback) {
838838
options = getOptions(options, {});
839839
path = getPathFromURL(path);
840840
validatePath(path, 'oldPath');
841-
const req = new FSReqWrap();
841+
const req = new FSReqCallback();
842842
req.oncomplete = callback;
843843
binding.readlink(pathModule.toNamespacedPath(path), options.encoding, req);
844844
}
@@ -864,7 +864,7 @@ function symlink(target, path, type_, callback_) {
864864
validatePath(path);
865865

866866
const flags = stringToSymlinkType(type);
867-
const req = new FSReqWrap();
867+
const req = new FSReqCallback();
868868
req.oncomplete = callback;
869869

870870
binding.symlink(preprocessSymlinkDestination(target, type, path),
@@ -894,7 +894,7 @@ function link(existingPath, newPath, callback) {
894894
validatePath(existingPath, 'existingPath');
895895
validatePath(newPath, 'newPath');
896896

897-
const req = new FSReqWrap();
897+
const req = new FSReqCallback();
898898
req.oncomplete = callback;
899899

900900
binding.link(pathModule.toNamespacedPath(existingPath),
@@ -920,7 +920,7 @@ function unlink(path, callback) {
920920
callback = makeCallback(callback);
921921
path = getPathFromURL(path);
922922
validatePath(path);
923-
const req = new FSReqWrap();
923+
const req = new FSReqCallback();
924924
req.oncomplete = callback;
925925
binding.unlink(pathModule.toNamespacedPath(path), req);
926926
}
@@ -938,7 +938,7 @@ function fchmod(fd, mode, callback) {
938938
mode = validateMode(mode, 'mode');
939939
callback = makeCallback(callback);
940940

941-
const req = new FSReqWrap();
941+
const req = new FSReqCallback();
942942
req.oncomplete = callback;
943943
binding.fchmod(fd, mode, req);
944944
}
@@ -989,7 +989,7 @@ function chmod(path, mode, callback) {
989989
mode = validateMode(mode, 'mode');
990990
callback = makeCallback(callback);
991991

992-
const req = new FSReqWrap();
992+
const req = new FSReqCallback();
993993
req.oncomplete = callback;
994994
binding.chmod(pathModule.toNamespacedPath(path), mode, req);
995995
}
@@ -1010,7 +1010,7 @@ function lchown(path, uid, gid, callback) {
10101010
validatePath(path);
10111011
validateUint32(uid, 'uid');
10121012
validateUint32(gid, 'gid');
1013-
const req = new FSReqWrap();
1013+
const req = new FSReqCallback();
10141014
req.oncomplete = callback;
10151015
binding.lchown(pathModule.toNamespacedPath(path), uid, gid, req);
10161016
}
@@ -1030,7 +1030,7 @@ function fchown(fd, uid, gid, callback) {
10301030
validateUint32(uid, 'uid');
10311031
validateUint32(gid, 'gid');
10321032

1033-
const req = new FSReqWrap();
1033+
const req = new FSReqCallback();
10341034
req.oncomplete = makeCallback(callback);
10351035
binding.fchown(fd, uid, gid, req);
10361036
}
@@ -1052,7 +1052,7 @@ function chown(path, uid, gid, callback) {
10521052
validateUint32(uid, 'uid');
10531053
validateUint32(gid, 'gid');
10541054

1055-
const req = new FSReqWrap();
1055+
const req = new FSReqCallback();
10561056
req.oncomplete = callback;
10571057
binding.chown(pathModule.toNamespacedPath(path), uid, gid, req);
10581058
}
@@ -1072,7 +1072,7 @@ function utimes(path, atime, mtime, callback) {
10721072
path = getPathFromURL(path);
10731073
validatePath(path);
10741074

1075-
const req = new FSReqWrap();
1075+
const req = new FSReqCallback();
10761076
req.oncomplete = callback;
10771077
binding.utimes(pathModule.toNamespacedPath(path),
10781078
toUnixTimestamp(atime),
@@ -1094,7 +1094,7 @@ function futimes(fd, atime, mtime, callback) {
10941094
validateUint32(fd, 'fd');
10951095
atime = toUnixTimestamp(atime, 'atime');
10961096
mtime = toUnixTimestamp(mtime, 'mtime');
1097-
const req = new FSReqWrap();
1097+
const req = new FSReqCallback();
10981098
req.oncomplete = makeCallback(callback);
10991099
binding.futimes(fd, atime, mtime, req);
11001100
}
@@ -1635,7 +1635,7 @@ realpath.native = function(path, options, callback) {
16351635
options = getOptions(options, {});
16361636
path = getPathFromURL(path);
16371637
validatePath(path);
1638-
const req = new FSReqWrap();
1638+
const req = new FSReqCallback();
16391639
req.oncomplete = callback;
16401640
return binding.realpath(path, options.encoding, req);
16411641
};
@@ -1647,7 +1647,7 @@ function mkdtemp(prefix, options, callback) {
16471647
throw new ERR_INVALID_ARG_TYPE('prefix', 'string', prefix);
16481648
}
16491649
nullCheck(prefix, 'prefix');
1650-
const req = new FSReqWrap();
1650+
const req = new FSReqCallback();
16511651
req.oncomplete = callback;
16521652
binding.mkdtemp(`${prefix}XXXXXX`, options.encoding, req);
16531653
}
@@ -1684,7 +1684,7 @@ function copyFile(src, dest, flags, callback) {
16841684
src = pathModule._makeLong(src);
16851685
dest = pathModule._makeLong(dest);
16861686
flags = flags | 0;
1687-
const req = new FSReqWrap();
1687+
const req = new FSReqCallback();
16881688
req.oncomplete = makeCallback(callback);
16891689
binding.copyFile(src, dest, flags, req);
16901690
}

lib/internal/fs/read_file_context.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { Buffer } = require('buffer');
4-
const { FSReqWrap, close, read } = process.binding('fs');
4+
const { FSReqCallback, close, read } = process.binding('fs');
55

66
const kReadFileBufferLength = 8 * 1024;
77

@@ -81,15 +81,15 @@ class ReadFileContext {
8181
length = Math.min(kReadFileBufferLength, this.size - this.pos);
8282
}
8383

84-
const req = new FSReqWrap();
84+
const req = new FSReqCallback();
8585
req.oncomplete = readFileAfterRead;
8686
req.context = this;
8787

8888
read(this.fd, buffer, offset, length, -1, req);
8989
}
9090

9191
close(err) {
92-
const req = new FSReqWrap();
92+
const req = new FSReqCallback();
9393
req.oncomplete = readFileAfterClose;
9494
req.context = this;
9595
this.err = err;

lib/internal/fs/streams.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const {
4-
FSReqWrap,
4+
FSReqCallback,
55
writeBuffers
66
} = process.binding('fs');
77
const {
@@ -330,7 +330,7 @@ function writev(fd, chunks, position, callback) {
330330
callback(err, written || 0, chunks);
331331
}
332332

333-
const req = new FSReqWrap();
333+
const req = new FSReqCallback();
334334
req.oncomplete = wrapper;
335335
writeBuffers(fd, chunks, position, req);
336336
}

0 commit comments

Comments
 (0)