@@ -603,30 +603,28 @@ async function readFileHandle(filehandle, options) {
603603// All of the functions are defined as async in order to ensure that errors
604604// thrown cause promise rejections rather than being thrown synchronously.
605605async function access ( path , mode = F_OK ) {
606- path = getValidatedPath ( path ) ;
607-
608606return await PromisePrototypeThen (
609- binding . access ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
607+ binding . access ( getValidatedPath ( path ) , mode , kUsePromises ) ,
610608undefined ,
611609handleErrorFromBinding ,
612610) ;
613611}
614612
615613async function cp ( src , dest , options ) {
616614options = 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' ) ;
619617return lazyLoadCpPromises ( ) ( src , dest , options ) ;
620618}
621619
622620async function copyFile ( src , dest , mode ) {
623- src = getValidatedPath ( src , 'src' ) ;
624- dest = getValidatedPath ( dest , 'dest' ) ;
625621return 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+ ) ,
630628undefined ,
631629handleErrorFromBinding ,
632630) ;
@@ -639,8 +637,7 @@ async function open(path, flags, mode) {
639637const flagsNumber = stringToFlags ( flags ) ;
640638mode = parseFileMode ( mode , 'mode' , 0o666 ) ;
641639return new FileHandle ( await PromisePrototypeThen (
642- binding . openFileHandle ( pathModule . toNamespacedPath ( path ) ,
643- flagsNumber , mode , kUsePromises ) ,
640+ binding . openFileHandle ( path , flagsNumber , mode , kUsePromises ) ,
644641undefined ,
645642handleErrorFromBinding ,
646643) ) ;
@@ -785,9 +782,7 @@ async function rename(oldPath, newPath) {
785782oldPath = getValidatedPath ( oldPath , 'oldPath' ) ;
786783newPath = getValidatedPath ( newPath , 'newPath' ) ;
787784return await PromisePrototypeThen (
788- binding . rename ( pathModule . toNamespacedPath ( oldPath ) ,
789- pathModule . toNamespacedPath ( newPath ) ,
790- kUsePromises ) ,
785+ binding . rename ( oldPath , newPath , kUsePromises ) ,
791786undefined ,
792787handleErrorFromBinding ,
793788) ;
@@ -809,13 +804,13 @@ async function ftruncate(handle, len = 0) {
809804}
810805
811806async function rm ( path , options ) {
812- path = pathModule . toNamespacedPath ( getValidatedPath ( path ) ) ;
807+ path = getValidatedPath ( path ) ;
813808options = await validateRmOptionsPromise ( path , options , false ) ;
814809return lazyRimRaf ( ) ( path , options ) ;
815810}
816811
817812async function rmdir ( path , options ) {
818- path = pathModule . toNamespacedPath ( getValidatedPath ( path ) ) ;
813+ path = getValidatedPath ( path ) ;
819814options = validateRmdirOptions ( options ) ;
820815
821816if ( options . recursive ) {
@@ -861,9 +856,12 @@ async function mkdir(path, options) {
861856validateBoolean ( recursive , 'options.recursive' ) ;
862857
863858return 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+ ) ,
867865undefined ,
868866handleErrorFromBinding ,
869867) ;
@@ -876,7 +874,7 @@ async function readdirRecursive(originalPath, options) {
876874originalPath ,
877875await PromisePrototypeThen (
878876binding . readdir (
879- pathModule . toNamespacedPath ( originalPath ) ,
877+ originalPath ,
880878options . encoding ,
881879! ! options . withFileTypes ,
882880kUsePromises ,
@@ -927,7 +925,7 @@ async function readdirRecursive(originalPath, options) {
927925direntPath ,
928926await PromisePrototypeThen (
929927binding . readdir (
930- pathModule . toNamespacedPath ( direntPath ) ,
928+ direntPath ,
931929options . encoding ,
932930false ,
933931kUsePromises ,
@@ -952,7 +950,7 @@ async function readdir(path, options) {
952950}
953951const result = await PromisePrototypeThen (
954952binding . readdir (
955- pathModule . toNamespacedPath ( path ) ,
953+ path ,
956954options . encoding ,
957955! ! options . withFileTypes ,
958956kUsePromises ,
@@ -969,8 +967,7 @@ async function readlink(path, options) {
969967options = getOptions ( options ) ;
970968path = getValidatedPath ( path , 'oldPath' ) ;
971969return await PromisePrototypeThen (
972- binding . readlink ( pathModule . toNamespacedPath ( path ) ,
973- options . encoding , kUsePromises ) ,
970+ binding . readlink ( path , options . encoding , kUsePromises ) ,
974971undefined ,
975972handleErrorFromBinding ,
976973) ;
@@ -1003,10 +1000,12 @@ async function symlink(target, path, type_) {
10031000target = getValidatedPath ( target , 'target' ) ;
10041001path = getValidatedPath ( path ) ;
10051002return 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+ ) ,
10101009undefined ,
10111010handleErrorFromBinding ,
10121011) ;
@@ -1022,32 +1021,26 @@ async function fstat(handle, options = { bigint: false }) {
10221021}
10231022
10241023async function lstat ( path , options = { bigint : false } ) {
1025- path = getValidatedPath ( path ) ;
10261024const result = await PromisePrototypeThen (
1027- binding . lstat ( pathModule . toNamespacedPath ( path ) ,
1028- options . bigint , kUsePromises ) ,
1025+ binding . lstat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
10291026undefined ,
10301027handleErrorFromBinding ,
10311028) ;
10321029return getStatsFromBinding ( result ) ;
10331030}
10341031
10351032async function stat ( path , options = { bigint : false } ) {
1036- path = getValidatedPath ( path ) ;
10371033const result = await PromisePrototypeThen (
1038- binding . stat ( pathModule . toNamespacedPath ( path ) ,
1039- options . bigint , kUsePromises ) ,
1034+ binding . stat ( getValidatedPath ( path ) , options . bigint , kUsePromises ) ,
10401035undefined ,
10411036handleErrorFromBinding ,
10421037) ;
10431038return getStatsFromBinding ( result ) ;
10441039}
10451040
10461041async function statfs ( path , options = { bigint : false } ) {
1047- path = getValidatedPath ( path ) ;
10481042const result = await PromisePrototypeThen (
1049- binding . statfs ( pathModule . toNamespacedPath ( path ) ,
1050- options . bigint , kUsePromises ) ,
1043+ binding . statfs ( path , options . bigint , kUsePromises ) ,
10511044undefined ,
10521045handleErrorFromBinding ,
10531046) ;
@@ -1058,18 +1051,15 @@ async function link(existingPath, newPath) {
10581051existingPath = getValidatedPath ( existingPath , 'existingPath' ) ;
10591052newPath = getValidatedPath ( newPath , 'newPath' ) ;
10601053return await PromisePrototypeThen (
1061- binding . link ( pathModule . toNamespacedPath ( existingPath ) ,
1062- pathModule . toNamespacedPath ( newPath ) ,
1063- kUsePromises ) ,
1054+ binding . link ( existingPath , newPath , kUsePromises ) ,
10641055undefined ,
10651056handleErrorFromBinding ,
10661057) ;
10671058}
10681059
10691060async function unlink ( path ) {
1070- path = getValidatedPath ( path ) ;
10711061return await PromisePrototypeThen (
1072- binding . unlink ( pathModule . toNamespacedPath ( path ) , kUsePromises ) ,
1062+ binding . unlink ( getValidatedPath ( path ) , kUsePromises ) ,
10731063undefined ,
10741064handleErrorFromBinding ,
10751065) ;
@@ -1088,7 +1078,7 @@ async function chmod(path, mode) {
10881078path = getValidatedPath ( path ) ;
10891079mode = parseFileMode ( mode , 'mode' ) ;
10901080return await PromisePrototypeThen (
1091- binding . chmod ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
1081+ binding . chmod ( path , mode , kUsePromises ) ,
10921082undefined ,
10931083handleErrorFromBinding ,
10941084) ;
@@ -1107,7 +1097,7 @@ async function lchown(path, uid, gid) {
11071097validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
11081098validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
11091099return await PromisePrototypeThen (
1110- binding . lchown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1100+ binding . lchown ( path , uid , gid , kUsePromises ) ,
11111101undefined ,
11121102handleErrorFromBinding ,
11131103) ;
@@ -1128,7 +1118,7 @@ async function chown(path, uid, gid) {
11281118validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
11291119validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
11301120return await PromisePrototypeThen (
1131- binding . chown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1121+ binding . chown ( path , uid , gid , kUsePromises ) ,
11321122undefined ,
11331123handleErrorFromBinding ,
11341124) ;
@@ -1137,10 +1127,12 @@ async function chown(path, uid, gid) {
11371127async function utimes ( path , atime , mtime ) {
11381128path = getValidatedPath ( path ) ;
11391129return 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+ ) ,
11441136undefined ,
11451137handleErrorFromBinding ,
11461138) ;
@@ -1157,22 +1149,22 @@ async function futimes(handle, atime, mtime) {
11571149}
11581150
11591151async function lutimes ( path , atime , mtime ) {
1160- path = getValidatedPath ( path ) ;
11611152return 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+ ) ,
11661159undefined ,
11671160handleErrorFromBinding ,
11681161) ;
11691162}
11701163
11711164async function realpath ( path , options ) {
11721165options = getOptions ( options ) ;
1173- path = getValidatedPath ( path ) ;
11741166return await PromisePrototypeThen (
1175- binding . realpath ( pathModule . toNamespacedPath ( path ) , options . encoding , kUsePromises ) ,
1167+ binding . realpath ( getValidatedPath ( path ) , options . encoding , kUsePromises ) ,
11761168undefined ,
11771169handleErrorFromBinding ,
11781170) ;
0 commit comments