@@ -395,14 +395,14 @@ function readFileSync(path, options) {
395
395
}
396
396
397
397
function close ( fd , callback ) {
398
- validateUint32 ( fd , 'fd' ) ;
398
+ validateInt32 ( fd , 'fd' , 0 ) ;
399
399
const req = new FSReqCallback ( ) ;
400
400
req . oncomplete = makeCallback ( callback ) ;
401
401
binding . close ( fd , req ) ;
402
402
}
403
403
404
404
function closeSync ( fd ) {
405
- validateUint32 ( fd , 'fd' ) ;
405
+ validateInt32 ( fd , 'fd' , 0 ) ;
406
406
407
407
const ctx = { } ;
408
408
binding . close ( fd , undefined , ctx ) ;
@@ -449,7 +449,7 @@ function openSync(path, flags, mode) {
449
449
}
450
450
451
451
function read ( fd , buffer , offset , length , position , callback ) {
452
- validateUint32 ( fd , 'fd' ) ;
452
+ validateInt32 ( fd , 'fd' , 0 ) ;
453
453
validateBuffer ( buffer ) ;
454
454
callback = maybeCallback ( callback ) ;
455
455
@@ -487,7 +487,7 @@ Object.defineProperty(read, internalUtil.customPromisifyArgs,
487
487
{ value : [ 'bytesRead' , 'buffer' ] , enumerable : false } ) ;
488
488
489
489
function readSync ( fd , buffer , offset , length , position ) {
490
- validateUint32 ( fd , 'fd' ) ;
490
+ validateInt32 ( fd , 'fd' , 0 ) ;
491
491
validateBuffer ( buffer ) ;
492
492
493
493
offset |= 0 ;
@@ -524,7 +524,7 @@ function write(fd, buffer, offset, length, position, callback) {
524
524
callback ( err , written || 0 , buffer ) ;
525
525
}
526
526
527
- validateUint32 ( fd , 'fd' ) ;
527
+ validateInt32 ( fd , 'fd' , 0 ) ;
528
528
529
529
const req = new FSReqCallback ( ) ;
530
530
req . oncomplete = wrapper ;
@@ -564,7 +564,7 @@ Object.defineProperty(write, internalUtil.customPromisifyArgs,
564
564
// OR
565
565
// fs.writeSync(fd, string[, position[, encoding]]);
566
566
function writeSync ( fd , buffer , offset , length , position ) {
567
- validateUint32 ( fd , 'fd' ) ;
567
+ validateInt32 ( fd , 'fd' , 0 ) ;
568
568
const ctx = { } ;
569
569
let result ;
570
570
if ( isArrayBufferView ( buffer ) ) {
@@ -661,7 +661,7 @@ function ftruncate(fd, len = 0, callback) {
661
661
callback = len ;
662
662
len = 0 ;
663
663
}
664
- validateUint32 ( fd , 'fd' ) ;
664
+ validateInt32 ( fd , 'fd' , 0 ) ;
665
665
validateInteger ( len , 'len' ) ;
666
666
len = Math . max ( 0 , len ) ;
667
667
const req = new FSReqCallback ( ) ;
@@ -670,7 +670,7 @@ function ftruncate(fd, len = 0, callback) {
670
670
}
671
671
672
672
function ftruncateSync ( fd , len = 0 ) {
673
- validateUint32 ( fd , 'fd' ) ;
673
+ validateInt32 ( fd , 'fd' , 0 ) ;
674
674
validateInteger ( len , 'len' ) ;
675
675
len = Math . max ( 0 , len ) ;
676
676
const ctx = { } ;
@@ -694,28 +694,28 @@ function rmdirSync(path) {
694
694
}
695
695
696
696
function fdatasync ( fd , callback ) {
697
- validateUint32 ( fd , 'fd' ) ;
697
+ validateInt32 ( fd , 'fd' , 0 ) ;
698
698
const req = new FSReqCallback ( ) ;
699
699
req . oncomplete = makeCallback ( callback ) ;
700
700
binding . fdatasync ( fd , req ) ;
701
701
}
702
702
703
703
function fdatasyncSync ( fd ) {
704
- validateUint32 ( fd , 'fd' ) ;
704
+ validateInt32 ( fd , 'fd' , 0 ) ;
705
705
const ctx = { } ;
706
706
binding . fdatasync ( fd , undefined , ctx ) ;
707
707
handleErrorFromBinding ( ctx ) ;
708
708
}
709
709
710
710
function fsync ( fd , callback ) {
711
- validateUint32 ( fd , 'fd' ) ;
711
+ validateInt32 ( fd , 'fd' , 0 ) ;
712
712
const req = new FSReqCallback ( ) ;
713
713
req . oncomplete = makeCallback ( callback ) ;
714
714
binding . fsync ( fd , req ) ;
715
715
}
716
716
717
717
function fsyncSync ( fd ) {
718
- validateUint32 ( fd , 'fd' ) ;
718
+ validateInt32 ( fd , 'fd' , 0 ) ;
719
719
const ctx = { } ;
720
720
binding . fsync ( fd , undefined , ctx ) ;
721
721
handleErrorFromBinding ( ctx ) ;
@@ -801,7 +801,7 @@ function fstat(fd, options, callback) {
801
801
callback = options ;
802
802
options = { } ;
803
803
}
804
- validateUint32 ( fd , 'fd' ) ;
804
+ validateInt32 ( fd , 'fd' , 0 ) ;
805
805
const req = new FSReqCallback ( options . bigint ) ;
806
806
req . oncomplete = makeStatsCallback ( callback ) ;
807
807
binding . fstat ( fd , options . bigint , req ) ;
@@ -832,7 +832,7 @@ function stat(path, options, callback) {
832
832
}
833
833
834
834
function fstatSync ( fd , options = { } ) {
835
- validateUint32 ( fd , 'fd' ) ;
835
+ validateInt32 ( fd , 'fd' , 0 ) ;
836
836
const ctx = { fd } ;
837
837
const stats = binding . fstat ( fd , options . bigint , undefined , ctx ) ;
838
838
handleErrorFromBinding ( ctx ) ;
@@ -1065,7 +1065,7 @@ function lchownSync(path, uid, gid) {
1065
1065
}
1066
1066
1067
1067
function fchown ( fd , uid , gid , callback ) {
1068
- validateUint32 ( fd , 'fd' ) ;
1068
+ validateInt32 ( fd , 'fd' , 0 ) ;
1069
1069
validateUint32 ( uid , 'uid' ) ;
1070
1070
validateUint32 ( gid , 'gid' ) ;
1071
1071
@@ -1075,7 +1075,7 @@ function fchown(fd, uid, gid, callback) {
1075
1075
}
1076
1076
1077
1077
function fchownSync ( fd , uid , gid ) {
1078
- validateUint32 ( fd , 'fd' ) ;
1078
+ validateInt32 ( fd , 'fd' , 0 ) ;
1079
1079
validateUint32 ( uid , 'uid' ) ;
1080
1080
validateUint32 ( gid , 'gid' ) ;
1081
1081
@@ -1126,7 +1126,7 @@ function utimesSync(path, atime, mtime) {
1126
1126
}
1127
1127
1128
1128
function futimes ( fd , atime , mtime , callback ) {
1129
- validateUint32 ( fd , 'fd' ) ;
1129
+ validateInt32 ( fd , 'fd' , 0 ) ;
1130
1130
atime = toUnixTimestamp ( atime , 'atime' ) ;
1131
1131
mtime = toUnixTimestamp ( mtime , 'mtime' ) ;
1132
1132
const req = new FSReqCallback ( ) ;
@@ -1135,7 +1135,7 @@ function futimes(fd, atime, mtime, callback) {
1135
1135
}
1136
1136
1137
1137
function futimesSync ( fd , atime , mtime ) {
1138
- validateUint32 ( fd , 'fd' ) ;
1138
+ validateInt32 ( fd , 'fd' , 0 ) ;
1139
1139
atime = toUnixTimestamp ( atime , 'atime' ) ;
1140
1140
mtime = toUnixTimestamp ( mtime , 'mtime' ) ;
1141
1141
const ctx = { } ;
0 commit comments