@@ -603,30 +603,28 @@ async function readFileHandle(filehandle, options) {
603
603
// All of the functions are defined as async in order to ensure that errors
604
604
// thrown cause promise rejections rather than being thrown synchronously.
605
605
async function access ( path , mode = F_OK ) {
606
- path = getValidatedPath ( path ) ;
607
-
608
606
return await PromisePrototypeThen (
609
- binding . access ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
607
+ binding . access ( getValidatedPath ( path ) , mode , kUsePromises ) ,
610
608
undefined ,
611
609
handleErrorFromBinding ,
612
610
) ;
613
611
}
614
612
615
613
async function cp ( src , dest , options ) {
616
614
options = validateCpOptions ( options ) ;
617
- src = pathModule . toNamespacedPath ( getValidatedPath ( src , 'src' ) ) ;
618
- dest = pathModule . toNamespacedPath ( getValidatedPath ( dest , 'dest' ) ) ;
615
+ src = getValidatedPath ( src , 'src' ) ;
616
+ dest = getValidatedPath ( dest , 'dest' ) ;
619
617
return lazyLoadCpPromises ( ) ( src , dest , options ) ;
620
618
}
621
619
622
620
async function copyFile ( src , dest , mode ) {
623
- src = getValidatedPath ( src , 'src' ) ;
624
- dest = getValidatedPath ( dest , 'dest' ) ;
625
621
return await PromisePrototypeThen (
626
- binding . copyFile ( pathModule . toNamespacedPath ( src ) ,
627
- pathModule . toNamespacedPath ( dest ) ,
628
- mode ,
629
- kUsePromises ) ,
622
+ binding . copyFile (
623
+ getValidatedPath ( src , 'src' ) ,
624
+ getValidatedPath ( dest , 'dest' ) ,
625
+ mode ,
626
+ kUsePromises ,
627
+ ) ,
630
628
undefined ,
631
629
handleErrorFromBinding ,
632
630
) ;
@@ -639,8 +637,7 @@ async function open(path, flags, mode) {
639
637
const flagsNumber = stringToFlags ( flags ) ;
640
638
mode = parseFileMode ( mode , 'mode' , 0o666 ) ;
641
639
return new FileHandle ( await PromisePrototypeThen (
642
- binding . openFileHandle ( pathModule . toNamespacedPath ( path ) ,
643
- flagsNumber , mode , kUsePromises ) ,
640
+ binding . openFileHandle ( path , flagsNumber , mode , kUsePromises ) ,
644
641
undefined ,
645
642
handleErrorFromBinding ,
646
643
) ) ;
@@ -785,9 +782,7 @@ async function rename(oldPath, newPath) {
785
782
oldPath = getValidatedPath ( oldPath , 'oldPath' ) ;
786
783
newPath = getValidatedPath ( newPath , 'newPath' ) ;
787
784
return await PromisePrototypeThen (
788
- binding . rename ( pathModule . toNamespacedPath ( oldPath ) ,
789
- pathModule . toNamespacedPath ( newPath ) ,
790
- kUsePromises ) ,
785
+ binding . rename ( oldPath , newPath , kUsePromises ) ,
791
786
undefined ,
792
787
handleErrorFromBinding ,
793
788
) ;
@@ -809,13 +804,13 @@ async function ftruncate(handle, len = 0) {
809
804
}
810
805
811
806
async function rm ( path , options ) {
812
- path = pathModule . toNamespacedPath ( getValidatedPath ( path ) ) ;
807
+ path = getValidatedPath ( path ) ;
813
808
options = await validateRmOptionsPromise ( path , options , false ) ;
814
809
return lazyRimRaf ( ) ( path , options ) ;
815
810
}
816
811
817
812
async function rmdir ( path , options ) {
818
- path = pathModule . toNamespacedPath ( getValidatedPath ( path ) ) ;
813
+ path = getValidatedPath ( path ) ;
819
814
options = validateRmdirOptions ( options ) ;
820
815
821
816
if ( options . recursive ) {
@@ -861,9 +856,12 @@ async function mkdir(path, options) {
861
856
validateBoolean ( recursive , 'options.recursive' ) ;
862
857
863
858
return await PromisePrototypeThen (
864
- binding . mkdir ( pathModule . toNamespacedPath ( path ) ,
865
- parseFileMode ( mode , 'mode' , 0o777 ) , recursive ,
866
- kUsePromises ) ,
859
+ binding . mkdir (
860
+ path ,
861
+ parseFileMode ( mode , 'mode' , 0o777 ) ,
862
+ recursive ,
863
+ kUsePromises ,
864
+ ) ,
867
865
undefined ,
868
866
handleErrorFromBinding ,
869
867
) ;
@@ -876,7 +874,7 @@ async function readdirRecursive(originalPath, options) {
876
874
originalPath ,
877
875
await PromisePrototypeThen (
878
876
binding . readdir (
879
- pathModule . toNamespacedPath ( originalPath ) ,
877
+ originalPath ,
880
878
options . encoding ,
881
879
! ! options . withFileTypes ,
882
880
kUsePromises ,
@@ -927,7 +925,7 @@ async function readdirRecursive(originalPath, options) {
927
925
direntPath ,
928
926
await PromisePrototypeThen (
929
927
binding . readdir (
930
- pathModule . toNamespacedPath ( direntPath ) ,
928
+ direntPath ,
931
929
options . encoding ,
932
930
false ,
933
931
kUsePromises ,
@@ -952,7 +950,7 @@ async function readdir(path, options) {
952
950
}
953
951
const result = await PromisePrototypeThen (
954
952
binding . readdir (
955
- pathModule . toNamespacedPath ( path ) ,
953
+ path ,
956
954
options . encoding ,
957
955
! ! options . withFileTypes ,
958
956
kUsePromises ,
@@ -969,8 +967,7 @@ async function readlink(path, options) {
969
967
options = getOptions ( options ) ;
970
968
path = getValidatedPath ( path , 'oldPath' ) ;
971
969
return await PromisePrototypeThen (
972
- binding . readlink ( pathModule . toNamespacedPath ( path ) ,
973
- options . encoding , kUsePromises ) ,
970
+ binding . readlink ( path , options . encoding , kUsePromises ) ,
974
971
undefined ,
975
972
handleErrorFromBinding ,
976
973
) ;
@@ -1003,10 +1000,12 @@ async function symlink(target, path, type_) {
1003
1000
target = getValidatedPath ( target , 'target' ) ;
1004
1001
path = getValidatedPath ( path ) ;
1005
1002
return await PromisePrototypeThen (
1006
- binding . symlink ( preprocessSymlinkDestination ( target , type , path ) ,
1007
- pathModule . toNamespacedPath ( path ) ,
1008
- stringToSymlinkType ( type ) ,
1009
- kUsePromises ) ,
1003
+ binding . symlink (
1004
+ preprocessSymlinkDestination ( target , type , path ) ,
1005
+ path ,
1006
+ stringToSymlinkType ( type ) ,
1007
+ kUsePromises ,
1008
+ ) ,
1010
1009
undefined ,
1011
1010
handleErrorFromBinding ,
1012
1011
) ;
@@ -1022,32 +1021,26 @@ async function fstat(handle, options = { bigint: false }) {
1022
1021
}
1023
1022
1024
1023
async function lstat ( path , options = { bigint : false } ) {
1025
- path = getValidatedPath ( path ) ;
1026
1024
const result = await PromisePrototypeThen (
1027
- binding . lstat ( pathModule . toNamespacedPath ( path ) ,
1028
- options . bigint , kUsePromises ) ,
1025
+ binding . lstat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
1029
1026
undefined ,
1030
1027
handleErrorFromBinding ,
1031
1028
) ;
1032
1029
return getStatsFromBinding ( result ) ;
1033
1030
}
1034
1031
1035
1032
async function stat ( path , options = { bigint : false } ) {
1036
- path = getValidatedPath ( path ) ;
1037
1033
const result = await PromisePrototypeThen (
1038
- binding . stat ( pathModule . toNamespacedPath ( path ) ,
1039
- options . bigint , kUsePromises ) ,
1034
+ binding . stat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
1040
1035
undefined ,
1041
1036
handleErrorFromBinding ,
1042
1037
) ;
1043
1038
return getStatsFromBinding ( result ) ;
1044
1039
}
1045
1040
1046
1041
async function statfs ( path , options = { bigint : false } ) {
1047
- path = getValidatedPath ( path ) ;
1048
1042
const result = await PromisePrototypeThen (
1049
- binding . statfs ( pathModule . toNamespacedPath ( path ) ,
1050
- options . bigint , kUsePromises ) ,
1043
+ binding . statfs ( path , options . bigint , kUsePromises ) ,
1051
1044
undefined ,
1052
1045
handleErrorFromBinding ,
1053
1046
) ;
@@ -1058,18 +1051,15 @@ async function link(existingPath, newPath) {
1058
1051
existingPath = getValidatedPath ( existingPath , 'existingPath' ) ;
1059
1052
newPath = getValidatedPath ( newPath , 'newPath' ) ;
1060
1053
return await PromisePrototypeThen (
1061
- binding . link ( pathModule . toNamespacedPath ( existingPath ) ,
1062
- pathModule . toNamespacedPath ( newPath ) ,
1063
- kUsePromises ) ,
1054
+ binding . link ( existingPath , newPath , kUsePromises ) ,
1064
1055
undefined ,
1065
1056
handleErrorFromBinding ,
1066
1057
) ;
1067
1058
}
1068
1059
1069
1060
async function unlink ( path ) {
1070
- path = getValidatedPath ( path ) ;
1071
1061
return await PromisePrototypeThen (
1072
- binding . unlink ( pathModule . toNamespacedPath ( path ) , kUsePromises ) ,
1062
+ binding . unlink ( getValidatedPath ( path ) , kUsePromises ) ,
1073
1063
undefined ,
1074
1064
handleErrorFromBinding ,
1075
1065
) ;
@@ -1088,7 +1078,7 @@ async function chmod(path, mode) {
1088
1078
path = getValidatedPath ( path ) ;
1089
1079
mode = parseFileMode ( mode , 'mode' ) ;
1090
1080
return await PromisePrototypeThen (
1091
- binding . chmod ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
1081
+ binding . chmod ( path , mode , kUsePromises ) ,
1092
1082
undefined ,
1093
1083
handleErrorFromBinding ,
1094
1084
) ;
@@ -1107,7 +1097,7 @@ async function lchown(path, uid, gid) {
1107
1097
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
1108
1098
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
1109
1099
return await PromisePrototypeThen (
1110
- binding . lchown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1100
+ binding . lchown ( path , uid , gid , kUsePromises ) ,
1111
1101
undefined ,
1112
1102
handleErrorFromBinding ,
1113
1103
) ;
@@ -1128,7 +1118,7 @@ async function chown(path, uid, gid) {
1128
1118
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
1129
1119
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
1130
1120
return await PromisePrototypeThen (
1131
- binding . chown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1121
+ binding . chown ( path , uid , gid , kUsePromises ) ,
1132
1122
undefined ,
1133
1123
handleErrorFromBinding ,
1134
1124
) ;
@@ -1137,10 +1127,12 @@ async function chown(path, uid, gid) {
1137
1127
async function utimes ( path , atime , mtime ) {
1138
1128
path = getValidatedPath ( path ) ;
1139
1129
return await PromisePrototypeThen (
1140
- binding . utimes ( pathModule . toNamespacedPath ( path ) ,
1141
- toUnixTimestamp ( atime ) ,
1142
- toUnixTimestamp ( mtime ) ,
1143
- kUsePromises ) ,
1130
+ binding . utimes (
1131
+ path ,
1132
+ toUnixTimestamp ( atime ) ,
1133
+ toUnixTimestamp ( mtime ) ,
1134
+ kUsePromises ,
1135
+ ) ,
1144
1136
undefined ,
1145
1137
handleErrorFromBinding ,
1146
1138
) ;
@@ -1157,22 +1149,22 @@ async function futimes(handle, atime, mtime) {
1157
1149
}
1158
1150
1159
1151
async function lutimes ( path , atime , mtime ) {
1160
- path = getValidatedPath ( path ) ;
1161
1152
return await PromisePrototypeThen (
1162
- binding . lutimes ( pathModule . toNamespacedPath ( path ) ,
1163
- toUnixTimestamp ( atime ) ,
1164
- toUnixTimestamp ( mtime ) ,
1165
- kUsePromises ) ,
1153
+ binding . lutimes (
1154
+ getValidatedPath ( path ) ,
1155
+ toUnixTimestamp ( atime ) ,
1156
+ toUnixTimestamp ( mtime ) ,
1157
+ kUsePromises ,
1158
+ ) ,
1166
1159
undefined ,
1167
1160
handleErrorFromBinding ,
1168
1161
) ;
1169
1162
}
1170
1163
1171
1164
async function realpath ( path , options ) {
1172
1165
options = getOptions ( options ) ;
1173
- path = getValidatedPath ( path ) ;
1174
1166
return await PromisePrototypeThen (
1175
- binding . realpath ( pathModule . toNamespacedPath ( path ) , options . encoding , kUsePromises ) ,
1167
+ binding . realpath ( getValidatedPath ( path ) , options . encoding , kUsePromises ) ,
1176
1168
undefined ,
1177
1169
handleErrorFromBinding ,
1178
1170
) ;
0 commit comments