Skip to content

Commit

Permalink
src,lib: rename FSReqWrap to FSReqCallback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
maclover7 committed Aug 1, 2018
1 parent 27a5338 commit 172b4d7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
66 changes: 33 additions & 33 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const {
ERR_INVALID_CALLBACK
} = errors.codes;

const { FSReqWrap, statValues } = binding;
const { FSReqCallback, statValues } = binding;
const internalFS = require('internal/fs/utils');
const { getPathFromURL } = require('internal/url');
const internalUtil = require('internal/util');
Expand Down Expand Up @@ -179,7 +179,7 @@ function access(path, mode, callback) {
validatePath(path);

mode = mode | 0;
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.access(pathModule.toNamespacedPath(path), mode, req);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ function readFileAfterOpen(err, fd) {

context.fd = fd;

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = readFileAfterStat;
req.context = context;
binding.fstat(fd, false, req);
Expand Down Expand Up @@ -284,7 +284,7 @@ function readFile(path, options, callback) {
const context = new ReadFileContext(callback, options.encoding);
context.isUserFd = isFd(path); // file descriptor ownership

const req = new FSReqWrap();
const req = new FSReqCallback();
req.context = context;
req.oncomplete = readFileAfterOpen;

Expand Down Expand Up @@ -393,7 +393,7 @@ function readFileSync(path, options) {

function close(fd, callback) {
validateUint32(fd, 'fd');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.close(fd, req);
}
Expand All @@ -418,7 +418,7 @@ function open(path, flags, mode, callback) {
callback = makeCallback(callback);
}

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;

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

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = wrapper;

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

validateUint32(fd, 'fd');

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = wrapper;

if (isUint8Array(buffer)) {
Expand Down Expand Up @@ -588,7 +588,7 @@ function rename(oldPath, newPath, callback) {
validatePath(oldPath, 'oldPath');
newPath = getPathFromURL(newPath);
validatePath(newPath, 'newPath');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.rename(pathModule.toNamespacedPath(oldPath),
pathModule.toNamespacedPath(newPath),
Expand Down Expand Up @@ -622,7 +622,7 @@ function truncate(path, len, callback) {
callback = maybeCallback(callback);
fs.open(path, 'r+', function(er, fd) {
if (er) return callback(er);
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = function oncomplete(er) {
fs.close(fd, function(er2) {
callback(er || er2);
Expand Down Expand Up @@ -661,7 +661,7 @@ function ftruncate(fd, len = 0, callback) {
validateUint32(fd, 'fd');
validateInteger(len, 'len');
len = Math.max(0, len);
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.ftruncate(fd, len, req);
}
Expand All @@ -679,7 +679,7 @@ function rmdir(path, callback) {
callback = makeCallback(callback);
path = getPathFromURL(path);
validatePath(path);
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.rmdir(pathModule.toNamespacedPath(path), req);
}
Expand All @@ -694,7 +694,7 @@ function rmdirSync(path) {

function fdatasync(fd, callback) {
validateUint32(fd, 'fd');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.fdatasync(fd, req);
}
Expand All @@ -708,7 +708,7 @@ function fdatasyncSync(fd) {

function fsync(fd, callback) {
validateUint32(fd, 'fd');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.fsync(fd, req);
}
Expand All @@ -732,7 +732,7 @@ function mkdir(path, mode, callback) {
mode = validateMode(mode, 'mode', 0o777);
}

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.mkdir(pathModule.toNamespacedPath(path), mode, req);
}
Expand All @@ -752,7 +752,7 @@ function readdir(path, options, callback) {
path = getPathFromURL(path);
validatePath(path);

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.readdir(pathModule.toNamespacedPath(path), options.encoding, req);
}
Expand All @@ -774,7 +774,7 @@ function fstat(fd, options, callback) {
options = {};
}
validateUint32(fd, 'fd');
const req = new FSReqWrap(options.bigint);
const req = new FSReqCallback(options.bigint);
req.oncomplete = makeStatsCallback(callback);
binding.fstat(fd, options.bigint, req);
}
Expand All @@ -787,7 +787,7 @@ function lstat(path, options, callback) {
callback = makeStatsCallback(callback);
path = getPathFromURL(path);
validatePath(path);
const req = new FSReqWrap(options.bigint);
const req = new FSReqCallback(options.bigint);
req.oncomplete = callback;
binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req);
}
Expand All @@ -800,7 +800,7 @@ function stat(path, options, callback) {
callback = makeStatsCallback(callback);
path = getPathFromURL(path);
validatePath(path);
const req = new FSReqWrap(options.bigint);
const req = new FSReqCallback(options.bigint);
req.oncomplete = callback;
binding.stat(pathModule.toNamespacedPath(path), options.bigint, req);
}
Expand Down Expand Up @@ -838,7 +838,7 @@ function readlink(path, options, callback) {
options = getOptions(options, {});
path = getPathFromURL(path);
validatePath(path, 'oldPath');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.readlink(pathModule.toNamespacedPath(path), options.encoding, req);
}
Expand All @@ -864,7 +864,7 @@ function symlink(target, path, type_, callback_) {
validatePath(path);

const flags = stringToSymlinkType(type);
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;

binding.symlink(preprocessSymlinkDestination(target, type, path),
Expand Down Expand Up @@ -894,7 +894,7 @@ function link(existingPath, newPath, callback) {
validatePath(existingPath, 'existingPath');
validatePath(newPath, 'newPath');

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;

binding.link(pathModule.toNamespacedPath(existingPath),
Expand All @@ -920,7 +920,7 @@ function unlink(path, callback) {
callback = makeCallback(callback);
path = getPathFromURL(path);
validatePath(path);
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.unlink(pathModule.toNamespacedPath(path), req);
}
Expand All @@ -938,7 +938,7 @@ function fchmod(fd, mode, callback) {
mode = validateMode(mode, 'mode');
callback = makeCallback(callback);

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.fchmod(fd, mode, req);
}
Expand Down Expand Up @@ -989,7 +989,7 @@ function chmod(path, mode, callback) {
mode = validateMode(mode, 'mode');
callback = makeCallback(callback);

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.chmod(pathModule.toNamespacedPath(path), mode, req);
}
Expand All @@ -1010,7 +1010,7 @@ function lchown(path, uid, gid, callback) {
validatePath(path);
validateUint32(uid, 'uid');
validateUint32(gid, 'gid');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.lchown(pathModule.toNamespacedPath(path), uid, gid, req);
}
Expand All @@ -1030,7 +1030,7 @@ function fchown(fd, uid, gid, callback) {
validateUint32(uid, 'uid');
validateUint32(gid, 'gid');

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.fchown(fd, uid, gid, req);
}
Expand All @@ -1052,7 +1052,7 @@ function chown(path, uid, gid, callback) {
validateUint32(uid, 'uid');
validateUint32(gid, 'gid');

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.chown(pathModule.toNamespacedPath(path), uid, gid, req);
}
Expand All @@ -1072,7 +1072,7 @@ function utimes(path, atime, mtime, callback) {
path = getPathFromURL(path);
validatePath(path);

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.utimes(pathModule.toNamespacedPath(path),
toUnixTimestamp(atime),
Expand All @@ -1094,7 +1094,7 @@ function futimes(fd, atime, mtime, callback) {
validateUint32(fd, 'fd');
atime = toUnixTimestamp(atime, 'atime');
mtime = toUnixTimestamp(mtime, 'mtime');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.futimes(fd, atime, mtime, req);
}
Expand Down Expand Up @@ -1635,7 +1635,7 @@ realpath.native = function(path, options, callback) {
options = getOptions(options, {});
path = getPathFromURL(path);
validatePath(path);
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
return binding.realpath(path, options.encoding, req);
};
Expand All @@ -1647,7 +1647,7 @@ function mkdtemp(prefix, options, callback) {
throw new ERR_INVALID_ARG_TYPE('prefix', 'string', prefix);
}
nullCheck(prefix, 'prefix');
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = callback;
binding.mkdtemp(`${prefix}XXXXXX`, options.encoding, req);
}
Expand Down Expand Up @@ -1684,7 +1684,7 @@ function copyFile(src, dest, flags, callback) {
src = pathModule._makeLong(src);
dest = pathModule._makeLong(dest);
flags = flags | 0;
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.copyFile(src, dest, flags, req);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/fs/read_file_context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

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

const kReadFileBufferLength = 8 * 1024;

Expand Down Expand Up @@ -81,15 +81,15 @@ class ReadFileContext {
length = Math.min(kReadFileBufferLength, this.size - this.pos);
}

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = readFileAfterRead;
req.context = this;

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

close(err) {
const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = readFileAfterClose;
req.context = this;
this.err = err;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/fs/streams.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const {
FSReqWrap,
FSReqCallback,
writeBuffers
} = process.binding('fs');
const {
Expand Down Expand Up @@ -330,7 +330,7 @@ function writev(fd, chunks, position, callback) {
callback(err, written || 0, chunks);
}

const req = new FSReqWrap();
const req = new FSReqCallback();
req.oncomplete = wrapper;
writeBuffers(fd, chunks, position, req);
}
Expand Down
Loading

0 comments on commit 172b4d7

Please sign in to comment.