@@ -597,10 +597,8 @@ async function readFileHandle(filehandle, options) {
597
597
// All of the functions are defined as async in order to ensure that errors
598
598
// thrown cause promise rejections rather than being thrown synchronously.
599
599
async function access ( path , mode = F_OK ) {
600
- path = getValidatedPath ( path ) ;
601
-
602
600
return await PromisePrototypeThen (
603
- binding . access ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
601
+ binding . access ( getValidatedPath ( path ) , mode , kUsePromises ) ,
604
602
undefined ,
605
603
handleErrorFromBinding ,
606
604
) ;
@@ -614,13 +612,13 @@ async function cp(src, dest, options) {
614
612
}
615
613
616
614
async function copyFile ( src , dest , mode ) {
617
- src = getValidatedPath ( src , 'src' ) ;
618
- dest = getValidatedPath ( dest , 'dest' ) ;
619
615
return await PromisePrototypeThen (
620
- binding . copyFile ( pathModule . toNamespacedPath ( src ) ,
621
- pathModule . toNamespacedPath ( dest ) ,
622
- mode ,
623
- kUsePromises ) ,
616
+ binding . copyFile (
617
+ getValidatedPath ( src , 'src' ) ,
618
+ getValidatedPath ( dest , 'dest' ) ,
619
+ mode ,
620
+ kUsePromises ,
621
+ ) ,
624
622
undefined ,
625
623
handleErrorFromBinding ,
626
624
) ;
@@ -633,8 +631,7 @@ async function open(path, flags, mode) {
633
631
const flagsNumber = stringToFlags ( flags ) ;
634
632
mode = parseFileMode ( mode , 'mode' , 0o666 ) ;
635
633
return new FileHandle ( await PromisePrototypeThen (
636
- binding . openFileHandle ( pathModule . toNamespacedPath ( path ) ,
637
- flagsNumber , mode , kUsePromises ) ,
634
+ binding . openFileHandle ( path , flagsNumber , mode , kUsePromises ) ,
638
635
undefined ,
639
636
handleErrorFromBinding ,
640
637
) ) ;
@@ -779,9 +776,7 @@ async function rename(oldPath, newPath) {
779
776
oldPath = getValidatedPath ( oldPath , 'oldPath' ) ;
780
777
newPath = getValidatedPath ( newPath , 'newPath' ) ;
781
778
return await PromisePrototypeThen (
782
- binding . rename ( pathModule . toNamespacedPath ( oldPath ) ,
783
- pathModule . toNamespacedPath ( newPath ) ,
784
- kUsePromises ) ,
779
+ binding . rename ( oldPath , newPath , kUsePromises ) ,
785
780
undefined ,
786
781
handleErrorFromBinding ,
787
782
) ;
@@ -870,7 +865,7 @@ async function readdirRecursive(originalPath, options) {
870
865
originalPath ,
871
866
await PromisePrototypeThen (
872
867
binding . readdir (
873
- pathModule . toNamespacedPath ( originalPath ) ,
868
+ originalPath ,
874
869
options . encoding ,
875
870
! ! options . withFileTypes ,
876
871
kUsePromises ,
@@ -921,7 +916,7 @@ async function readdirRecursive(originalPath, options) {
921
916
direntPath ,
922
917
await PromisePrototypeThen (
923
918
binding . readdir (
924
- pathModule . toNamespacedPath ( direntPath ) ,
919
+ direntPath ,
925
920
options . encoding ,
926
921
false ,
927
922
kUsePromises ,
@@ -946,7 +941,7 @@ async function readdir(path, options) {
946
941
}
947
942
const result = await PromisePrototypeThen (
948
943
binding . readdir (
949
- pathModule . toNamespacedPath ( path ) ,
944
+ path ,
950
945
options . encoding ,
951
946
! ! options . withFileTypes ,
952
947
kUsePromises ,
@@ -963,8 +958,7 @@ async function readlink(path, options) {
963
958
options = getOptions ( options ) ;
964
959
path = getValidatedPath ( path , 'oldPath' ) ;
965
960
return await PromisePrototypeThen (
966
- binding . readlink ( pathModule . toNamespacedPath ( path ) ,
967
- options . encoding , kUsePromises ) ,
961
+ binding . readlink ( path , options . encoding , kUsePromises ) ,
968
962
undefined ,
969
963
handleErrorFromBinding ,
970
964
) ;
@@ -993,10 +987,12 @@ async function symlink(target, path, type_) {
993
987
target = getValidatedPath ( target , 'target' ) ;
994
988
path = getValidatedPath ( path ) ;
995
989
return await PromisePrototypeThen (
996
- binding . symlink ( preprocessSymlinkDestination ( target , type , path ) ,
997
- pathModule . toNamespacedPath ( path ) ,
998
- stringToSymlinkType ( type ) ,
999
- kUsePromises ) ,
990
+ binding . symlink (
991
+ preprocessSymlinkDestination ( target , type , path ) ,
992
+ path ,
993
+ stringToSymlinkType ( type ) ,
994
+ kUsePromises ,
995
+ ) ,
1000
996
undefined ,
1001
997
handleErrorFromBinding ,
1002
998
) ;
@@ -1012,32 +1008,26 @@ async function fstat(handle, options = { bigint: false }) {
1012
1008
}
1013
1009
1014
1010
async function lstat ( path , options = { bigint : false } ) {
1015
- path = getValidatedPath ( path ) ;
1016
1011
const result = await PromisePrototypeThen (
1017
- binding . lstat ( pathModule . toNamespacedPath ( path ) ,
1018
- options . bigint , kUsePromises ) ,
1012
+ binding . lstat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
1019
1013
undefined ,
1020
1014
handleErrorFromBinding ,
1021
1015
) ;
1022
1016
return getStatsFromBinding ( result ) ;
1023
1017
}
1024
1018
1025
1019
async function stat ( path , options = { bigint : false } ) {
1026
- path = getValidatedPath ( path ) ;
1027
1020
const result = await PromisePrototypeThen (
1028
- binding . stat ( pathModule . toNamespacedPath ( path ) ,
1029
- options . bigint , kUsePromises ) ,
1021
+ binding . stat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
1030
1022
undefined ,
1031
1023
handleErrorFromBinding ,
1032
1024
) ;
1033
1025
return getStatsFromBinding ( result ) ;
1034
1026
}
1035
1027
1036
1028
async function statfs ( path , options = { bigint : false } ) {
1037
- path = getValidatedPath ( path ) ;
1038
1029
const result = await PromisePrototypeThen (
1039
- binding . statfs ( pathModule . toNamespacedPath ( path ) ,
1040
- options . bigint , kUsePromises ) ,
1030
+ binding . statfs ( path , options . bigint , kUsePromises ) ,
1041
1031
undefined ,
1042
1032
handleErrorFromBinding ,
1043
1033
) ;
@@ -1048,18 +1038,15 @@ async function link(existingPath, newPath) {
1048
1038
existingPath = getValidatedPath ( existingPath , 'existingPath' ) ;
1049
1039
newPath = getValidatedPath ( newPath , 'newPath' ) ;
1050
1040
return await PromisePrototypeThen (
1051
- binding . link ( pathModule . toNamespacedPath ( existingPath ) ,
1052
- pathModule . toNamespacedPath ( newPath ) ,
1053
- kUsePromises ) ,
1041
+ binding . link ( existingPath , newPath , kUsePromises ) ,
1054
1042
undefined ,
1055
1043
handleErrorFromBinding ,
1056
1044
) ;
1057
1045
}
1058
1046
1059
1047
async function unlink ( path ) {
1060
- path = getValidatedPath ( path ) ;
1061
1048
return await PromisePrototypeThen (
1062
- binding . unlink ( pathModule . toNamespacedPath ( path ) , kUsePromises ) ,
1049
+ binding . unlink ( getValidatedPath ( path ) , kUsePromises ) ,
1063
1050
undefined ,
1064
1051
handleErrorFromBinding ,
1065
1052
) ;
@@ -1078,7 +1065,7 @@ async function chmod(path, mode) {
1078
1065
path = getValidatedPath ( path ) ;
1079
1066
mode = parseFileMode ( mode , 'mode' ) ;
1080
1067
return await PromisePrototypeThen (
1081
- binding . chmod ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
1068
+ binding . chmod ( path , mode , kUsePromises ) ,
1082
1069
undefined ,
1083
1070
handleErrorFromBinding ,
1084
1071
) ;
@@ -1097,7 +1084,7 @@ async function lchown(path, uid, gid) {
1097
1084
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
1098
1085
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
1099
1086
return await PromisePrototypeThen (
1100
- binding . lchown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1087
+ binding . lchown ( path , uid , gid , kUsePromises ) ,
1101
1088
undefined ,
1102
1089
handleErrorFromBinding ,
1103
1090
) ;
@@ -1118,7 +1105,7 @@ async function chown(path, uid, gid) {
1118
1105
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
1119
1106
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
1120
1107
return await PromisePrototypeThen (
1121
- binding . chown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1108
+ binding . chown ( path , uid , gid , kUsePromises ) ,
1122
1109
undefined ,
1123
1110
handleErrorFromBinding ,
1124
1111
) ;
@@ -1127,10 +1114,12 @@ async function chown(path, uid, gid) {
1127
1114
async function utimes ( path , atime , mtime ) {
1128
1115
path = getValidatedPath ( path ) ;
1129
1116
return await PromisePrototypeThen (
1130
- binding . utimes ( pathModule . toNamespacedPath ( path ) ,
1131
- toUnixTimestamp ( atime ) ,
1132
- toUnixTimestamp ( mtime ) ,
1133
- kUsePromises ) ,
1117
+ binding . utimes (
1118
+ path ,
1119
+ toUnixTimestamp ( atime ) ,
1120
+ toUnixTimestamp ( mtime ) ,
1121
+ kUsePromises ,
1122
+ ) ,
1134
1123
undefined ,
1135
1124
handleErrorFromBinding ,
1136
1125
) ;
@@ -1147,22 +1136,22 @@ async function futimes(handle, atime, mtime) {
1147
1136
}
1148
1137
1149
1138
async function lutimes ( path , atime , mtime ) {
1150
- path = getValidatedPath ( path ) ;
1151
1139
return await PromisePrototypeThen (
1152
- binding . lutimes ( pathModule . toNamespacedPath ( path ) ,
1153
- toUnixTimestamp ( atime ) ,
1154
- toUnixTimestamp ( mtime ) ,
1155
- kUsePromises ) ,
1140
+ binding . lutimes (
1141
+ getValidatedPath ( path ) ,
1142
+ toUnixTimestamp ( atime ) ,
1143
+ toUnixTimestamp ( mtime ) ,
1144
+ kUsePromises ,
1145
+ ) ,
1156
1146
undefined ,
1157
1147
handleErrorFromBinding ,
1158
1148
) ;
1159
1149
}
1160
1150
1161
1151
async function realpath ( path , options ) {
1162
1152
options = getOptions ( options ) ;
1163
- path = getValidatedPath ( path ) ;
1164
1153
return await PromisePrototypeThen (
1165
- binding . realpath ( pathModule . toNamespacedPath ( path ) , options . encoding , kUsePromises ) ,
1154
+ binding . realpath ( getValidatedPath ( path ) , options . encoding , kUsePromises ) ,
1166
1155
undefined ,
1167
1156
handleErrorFromBinding ,
1168
1157
) ;
0 commit comments