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