@@ -132,14 +132,6 @@ const {
132132const {
133133 CHAR_FORWARD_SLASH ,
134134 CHAR_BACKWARD_SLASH ,
135- CHAR_COLON ,
136- CHAR_QUESTION_MARK ,
137- CHAR_UPPERCASE_A ,
138- CHAR_UPPERCASE_C ,
139- CHAR_UPPERCASE_Z ,
140- CHAR_LOWERCASE_A ,
141- CHAR_LOWERCASE_N ,
142- CHAR_LOWERCASE_Z ,
143135} = require ( 'internal/constants' ) ;
144136const {
145137 isInt32,
@@ -2636,43 +2628,6 @@ function unwatchFile(filename, listener) {
26362628}
26372629
26382630
2639- // Strips the Windows extended-length path prefix (\\?\) from a resolved path.
2640- // Extended-length paths (\\?\C:\... or \\?\UNC\...) are a Win32 API mechanism
2641- // to bypass MAX_PATH limits. Node.js should handle them transparently by
2642- // converting to standard paths for internal processing. The \\?\ prefix is
2643- // re-added when needed via path.toNamespacedPath() before system calls.
2644- // See: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file
2645- function stripExtendedPathPrefix ( p ) {
2646- // Check for \\?\ prefix
2647- if ( p . length >= 4 &&
2648- StringPrototypeCharCodeAt ( p , 0 ) === CHAR_BACKWARD_SLASH &&
2649- StringPrototypeCharCodeAt ( p , 1 ) === CHAR_BACKWARD_SLASH &&
2650- StringPrototypeCharCodeAt ( p , 2 ) === CHAR_QUESTION_MARK &&
2651- StringPrototypeCharCodeAt ( p , 3 ) === CHAR_BACKWARD_SLASH ) {
2652- // \\?\C:\ -> C:\ (extended drive path)
2653- if ( p . length >= 6 ) {
2654- const drive = StringPrototypeCharCodeAt ( p , 4 ) ;
2655- if ( ( ( drive >= CHAR_UPPERCASE_A && drive <= CHAR_UPPERCASE_Z ) ||
2656- ( drive >= CHAR_LOWERCASE_A && drive <= CHAR_LOWERCASE_Z ) ) &&
2657- StringPrototypeCharCodeAt ( p , 5 ) === CHAR_COLON ) {
2658- return StringPrototypeSlice ( p , 4 ) ;
2659- }
2660- }
2661- // \\?\UNC\server\share -> \\server\share (extended UNC path)
2662- if ( p . length >= 8 &&
2663- ( StringPrototypeCharCodeAt ( p , 4 ) === 85 /* U */ ||
2664- StringPrototypeCharCodeAt ( p , 4 ) === 117 /* u */ ) &&
2665- ( StringPrototypeCharCodeAt ( p , 5 ) === 78 /* N */ ||
2666- StringPrototypeCharCodeAt ( p , 5 ) === CHAR_LOWERCASE_N ) &&
2667- ( StringPrototypeCharCodeAt ( p , 6 ) === CHAR_UPPERCASE_C ||
2668- StringPrototypeCharCodeAt ( p , 6 ) === 99 /* c */ ) &&
2669- StringPrototypeCharCodeAt ( p , 7 ) === CHAR_BACKWARD_SLASH ) {
2670- return '\\\\' + StringPrototypeSlice ( p , 8 ) ;
2671- }
2672- }
2673- return p ;
2674- }
2675-
26762631let splitRoot ;
26772632if ( isWindows ) {
26782633 // Regex to find the device root on Windows (e.g. 'c:\\'), including trailing
@@ -2735,12 +2690,6 @@ function realpathSync(p, options) {
27352690 validatePath ( p ) ;
27362691 p = pathModule . resolve ( p ) ;
27372692
2738- // On Windows, strip the extended-length path prefix (\\?\) so that the
2739- // path walking logic below works with standard drive-letter or UNC roots.
2740- if ( isWindows ) {
2741- p = stripExtendedPathPrefix ( p ) ;
2742- }
2743-
27442693 const cache = options [ realpathCacheKey ] ;
27452694 const maybeCachedResult = cache ?. get ( p ) ;
27462695 if ( maybeCachedResult ) {
@@ -2844,11 +2793,6 @@ function realpathSync(p, options) {
28442793 // Resolve the link, then start over
28452794 p = pathModule . resolve ( resolvedLink , StringPrototypeSlice ( p , pos ) ) ;
28462795
2847- // Strip extended path prefix again in case pathModule.resolve re-added it
2848- if ( isWindows ) {
2849- p = stripExtendedPathPrefix ( p ) ;
2850- }
2851-
28522796 // Skip over roots
28532797 current = base = splitRoot ( p ) ;
28542798 pos = current . length ;
@@ -2907,12 +2851,6 @@ function realpath(p, options, callback) {
29072851 validatePath ( p ) ;
29082852 p = pathModule . resolve ( p ) ;
29092853
2910- // On Windows, strip the extended-length path prefix (\\?\) so that the
2911- // path walking logic below works with standard drive-letter or UNC roots.
2912- if ( isWindows ) {
2913- p = stripExtendedPathPrefix ( p ) ;
2914- }
2915-
29162854 const seenLinks = new SafeMap ( ) ;
29172855 const knownHard = new SafeSet ( ) ;
29182856
@@ -3013,12 +2951,6 @@ function realpath(p, options, callback) {
30132951 function gotResolvedLink ( resolvedLink ) {
30142952 // Resolve the link, then start over
30152953 p = pathModule . resolve ( resolvedLink , StringPrototypeSlice ( p , pos ) ) ;
3016-
3017- // Strip extended path prefix again in case pathModule.resolve re-added it
3018- if ( isWindows ) {
3019- p = stripExtendedPathPrefix ( p ) ;
3020- }
3021-
30222954 current = base = splitRoot ( p ) ;
30232955 pos = current . length ;
30242956
0 commit comments