@@ -597,30 +597,28 @@ 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
) ;
607
605
}
608
606
609
607
async function cp ( src , dest , options ) {
610
608
options = validateCpOptions ( options ) ;
611
- src = pathModule . toNamespacedPath ( getValidatedPath ( src , 'src' ) ) ;
612
- dest = pathModule . toNamespacedPath ( getValidatedPath ( dest , 'dest' ) ) ;
609
+ src = getValidatedPath ( src , 'src' ) ;
610
+ dest = getValidatedPath ( dest , 'dest' ) ;
613
611
return lazyLoadCpPromises ( ) ( 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
) ;
@@ -803,13 +798,13 @@ async function ftruncate(handle, len = 0) {
803
798
}
804
799
805
800
async function rm ( path , options ) {
806
- path = pathModule . toNamespacedPath ( getValidatedPath ( path ) ) ;
801
+ path = getValidatedPath ( path ) ;
807
802
options = await validateRmOptionsPromise ( path , options , false ) ;
808
803
return lazyRimRaf ( ) ( path , options ) ;
809
804
}
810
805
811
806
async function rmdir ( path , options ) {
812
- path = pathModule . toNamespacedPath ( getValidatedPath ( path ) ) ;
807
+ path = getValidatedPath ( path ) ;
813
808
options = validateRmdirOptions ( options ) ;
814
809
815
810
if ( options . recursive ) {
@@ -855,9 +850,12 @@ async function mkdir(path, options) {
855
850
validateBoolean ( recursive , 'options.recursive' ) ;
856
851
857
852
return await PromisePrototypeThen (
858
- binding . mkdir ( pathModule . toNamespacedPath ( path ) ,
859
- parseFileMode ( mode , 'mode' , 0o777 ) , recursive ,
860
- kUsePromises ) ,
853
+ binding . mkdir (
854
+ path ,
855
+ parseFileMode ( mode , 'mode' , 0o777 ) ,
856
+ recursive ,
857
+ kUsePromises ,
858
+ ) ,
861
859
undefined ,
862
860
handleErrorFromBinding ,
863
861
) ;
@@ -870,7 +868,7 @@ async function readdirRecursive(originalPath, options) {
870
868
originalPath ,
871
869
await PromisePrototypeThen (
872
870
binding . readdir (
873
- pathModule . toNamespacedPath ( originalPath ) ,
871
+ originalPath ,
874
872
options . encoding ,
875
873
! ! options . withFileTypes ,
876
874
kUsePromises ,
@@ -921,7 +919,7 @@ async function readdirRecursive(originalPath, options) {
921
919
direntPath ,
922
920
await PromisePrototypeThen (
923
921
binding . readdir (
924
- pathModule . toNamespacedPath ( direntPath ) ,
922
+ direntPath ,
925
923
options . encoding ,
926
924
false ,
927
925
kUsePromises ,
@@ -946,7 +944,7 @@ async function readdir(path, options) {
946
944
}
947
945
const result = await PromisePrototypeThen (
948
946
binding . readdir (
949
- pathModule . toNamespacedPath ( path ) ,
947
+ path ,
950
948
options . encoding ,
951
949
! ! options . withFileTypes ,
952
950
kUsePromises ,
@@ -963,8 +961,7 @@ async function readlink(path, options) {
963
961
options = getOptions ( options ) ;
964
962
path = getValidatedPath ( path , 'oldPath' ) ;
965
963
return await PromisePrototypeThen (
966
- binding . readlink ( pathModule . toNamespacedPath ( path ) ,
967
- options . encoding , kUsePromises ) ,
964
+ binding . readlink ( path , options . encoding , kUsePromises ) ,
968
965
undefined ,
969
966
handleErrorFromBinding ,
970
967
) ;
@@ -993,10 +990,12 @@ async function symlink(target, path, type_) {
993
990
target = getValidatedPath ( target , 'target' ) ;
994
991
path = getValidatedPath ( path ) ;
995
992
return await PromisePrototypeThen (
996
- binding . symlink ( preprocessSymlinkDestination ( target , type , path ) ,
997
- pathModule . toNamespacedPath ( path ) ,
998
- stringToSymlinkType ( type ) ,
999
- kUsePromises ) ,
993
+ binding . symlink (
994
+ preprocessSymlinkDestination ( target , type , path ) ,
995
+ path ,
996
+ stringToSymlinkType ( type ) ,
997
+ kUsePromises ,
998
+ ) ,
1000
999
undefined ,
1001
1000
handleErrorFromBinding ,
1002
1001
) ;
@@ -1012,32 +1011,26 @@ async function fstat(handle, options = { bigint: false }) {
1012
1011
}
1013
1012
1014
1013
async function lstat ( path , options = { bigint : false } ) {
1015
- path = getValidatedPath ( path ) ;
1016
1014
const result = await PromisePrototypeThen (
1017
- binding . lstat ( pathModule . toNamespacedPath ( path ) ,
1018
- options . bigint , kUsePromises ) ,
1015
+ binding . lstat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
1019
1016
undefined ,
1020
1017
handleErrorFromBinding ,
1021
1018
) ;
1022
1019
return getStatsFromBinding ( result ) ;
1023
1020
}
1024
1021
1025
1022
async function stat ( path , options = { bigint : false } ) {
1026
- path = getValidatedPath ( path ) ;
1027
1023
const result = await PromisePrototypeThen (
1028
- binding . stat ( pathModule . toNamespacedPath ( path ) ,
1029
- options . bigint , kUsePromises ) ,
1024
+ binding . stat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
1030
1025
undefined ,
1031
1026
handleErrorFromBinding ,
1032
1027
) ;
1033
1028
return getStatsFromBinding ( result ) ;
1034
1029
}
1035
1030
1036
1031
async function statfs ( path , options = { bigint : false } ) {
1037
- path = getValidatedPath ( path ) ;
1038
1032
const result = await PromisePrototypeThen (
1039
- binding . statfs ( pathModule . toNamespacedPath ( path ) ,
1040
- options . bigint , kUsePromises ) ,
1033
+ binding . statfs ( path , options . bigint , kUsePromises ) ,
1041
1034
undefined ,
1042
1035
handleErrorFromBinding ,
1043
1036
) ;
@@ -1048,18 +1041,15 @@ async function link(existingPath, newPath) {
1048
1041
existingPath = getValidatedPath ( existingPath , 'existingPath' ) ;
1049
1042
newPath = getValidatedPath ( newPath , 'newPath' ) ;
1050
1043
return await PromisePrototypeThen (
1051
- binding . link ( pathModule . toNamespacedPath ( existingPath ) ,
1052
- pathModule . toNamespacedPath ( newPath ) ,
1053
- kUsePromises ) ,
1044
+ binding . link ( existingPath , newPath , kUsePromises ) ,
1054
1045
undefined ,
1055
1046
handleErrorFromBinding ,
1056
1047
) ;
1057
1048
}
1058
1049
1059
1050
async function unlink ( path ) {
1060
- path = getValidatedPath ( path ) ;
1061
1051
return await PromisePrototypeThen (
1062
- binding . unlink ( pathModule . toNamespacedPath ( path ) , kUsePromises ) ,
1052
+ binding . unlink ( getValidatedPath ( path ) , kUsePromises ) ,
1063
1053
undefined ,
1064
1054
handleErrorFromBinding ,
1065
1055
) ;
@@ -1078,7 +1068,7 @@ async function chmod(path, mode) {
1078
1068
path = getValidatedPath ( path ) ;
1079
1069
mode = parseFileMode ( mode , 'mode' ) ;
1080
1070
return await PromisePrototypeThen (
1081
- binding . chmod ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
1071
+ binding . chmod ( path , mode , kUsePromises ) ,
1082
1072
undefined ,
1083
1073
handleErrorFromBinding ,
1084
1074
) ;
@@ -1097,7 +1087,7 @@ async function lchown(path, uid, gid) {
1097
1087
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
1098
1088
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
1099
1089
return await PromisePrototypeThen (
1100
- binding . lchown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1090
+ binding . lchown ( path , uid , gid , kUsePromises ) ,
1101
1091
undefined ,
1102
1092
handleErrorFromBinding ,
1103
1093
) ;
@@ -1118,7 +1108,7 @@ async function chown(path, uid, gid) {
1118
1108
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
1119
1109
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
1120
1110
return await PromisePrototypeThen (
1121
- binding . chown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1111
+ binding . chown ( path , uid , gid , kUsePromises ) ,
1122
1112
undefined ,
1123
1113
handleErrorFromBinding ,
1124
1114
) ;
@@ -1127,10 +1117,12 @@ async function chown(path, uid, gid) {
1127
1117
async function utimes ( path , atime , mtime ) {
1128
1118
path = getValidatedPath ( path ) ;
1129
1119
return await PromisePrototypeThen (
1130
- binding . utimes ( pathModule . toNamespacedPath ( path ) ,
1131
- toUnixTimestamp ( atime ) ,
1132
- toUnixTimestamp ( mtime ) ,
1133
- kUsePromises ) ,
1120
+ binding . utimes (
1121
+ path ,
1122
+ toUnixTimestamp ( atime ) ,
1123
+ toUnixTimestamp ( mtime ) ,
1124
+ kUsePromises ,
1125
+ ) ,
1134
1126
undefined ,
1135
1127
handleErrorFromBinding ,
1136
1128
) ;
@@ -1147,22 +1139,22 @@ async function futimes(handle, atime, mtime) {
1147
1139
}
1148
1140
1149
1141
async function lutimes ( path , atime , mtime ) {
1150
- path = getValidatedPath ( path ) ;
1151
1142
return await PromisePrototypeThen (
1152
- binding . lutimes ( pathModule . toNamespacedPath ( path ) ,
1153
- toUnixTimestamp ( atime ) ,
1154
- toUnixTimestamp ( mtime ) ,
1155
- kUsePromises ) ,
1143
+ binding . lutimes (
1144
+ getValidatedPath ( path ) ,
1145
+ toUnixTimestamp ( atime ) ,
1146
+ toUnixTimestamp ( mtime ) ,
1147
+ kUsePromises ,
1148
+ ) ,
1156
1149
undefined ,
1157
1150
handleErrorFromBinding ,
1158
1151
) ;
1159
1152
}
1160
1153
1161
1154
async function realpath ( path , options ) {
1162
1155
options = getOptions ( options ) ;
1163
- path = getValidatedPath ( path ) ;
1164
1156
return await PromisePrototypeThen (
1165
- binding . realpath ( pathModule . toNamespacedPath ( path ) , options . encoding , kUsePromises ) ,
1157
+ binding . realpath ( getValidatedPath ( path ) , options . encoding , kUsePromises ) ,
1166
1158
undefined ,
1167
1159
handleErrorFromBinding ,
1168
1160
) ;
0 commit comments