summaryrefslogtreecommitdiff
path: root/lib/fs.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fs.js')
-rw-r--r--lib/fs.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/fs.js b/lib/fs.js
index d71e31565f..c49d470f03 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -51,7 +51,6 @@ const internalUtil = require('internal/util');
const {
copyObject,
getOptions,
- isUint32,
modeNum,
nullCheck,
preprocessSymlinkDestination,
@@ -61,16 +60,19 @@ const {
stringToSymlinkType,
toUnixTimestamp,
validateBuffer,
- validateLen,
validateOffsetLengthRead,
validateOffsetLengthWrite,
- validatePath,
- validateUint32
+ validatePath
} = internalFS;
const {
CHAR_FORWARD_SLASH,
CHAR_BACKWARD_SLASH,
} = require('internal/constants');
+const {
+ isUint32,
+ validateInt32,
+ validateUint32
+} = require('internal/validators');
Object.defineProperty(exports, 'constants', {
configurable: false,
@@ -755,8 +757,8 @@ fs.ftruncate = function(fd, len = 0, callback) {
// TODO(BridgeAR): This does not seem right.
// There does not seem to be any validation before and if there is any, it
// should work similar to validateUint32 or not have a upper cap at all.
- // This applies to all usage of `validateLen`.
- validateLen(len);
+ // This applies to all usage of `validateInt32(len, 'len')`.
+ validateInt32(len, 'len');
len = Math.max(0, len);
const req = new FSReqWrap();
req.oncomplete = makeCallback(callback);
@@ -765,7 +767,7 @@ fs.ftruncate = function(fd, len = 0, callback) {
fs.ftruncateSync = function(fd, len = 0) {
validateUint32(fd, 'fd');
- validateLen(len);
+ validateInt32(len, 'len');
len = Math.max(0, len);
const ctx = {};
binding.ftruncate(fd, len, undefined, ctx);