@@ -120,68 +120,18 @@ class _WindowsFlavour(_Flavour):
120120
121121 is_supported = (os .name == 'nt' )
122122
123- drive_letters = set ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )
124- ext_namespace_prefix = '\\ \\ ?\\ '
125-
126123 reserved_names = (
127124 {'CON' , 'PRN' , 'AUX' , 'NUL' , 'CONIN$' , 'CONOUT$' } |
128125 {'COM%s' % c for c in '123456789\xb9 \xb2 \xb3 ' } |
129126 {'LPT%s' % c for c in '123456789\xb9 \xb2 \xb3 ' }
130127 )
131128
132- # Interesting findings about extended paths:
133- # * '\\?\c:\a' is an extended path, which bypasses normal Windows API
134- # path processing. Thus relative paths are not resolved and slash is not
135- # translated to backslash. It has the native NT path limit of 32767
136- # characters, but a bit less after resolving device symbolic links,
137- # such as '\??\C:' => '\Device\HarddiskVolume2'.
138- # * '\\?\c:/a' looks for a device named 'C:/a' because slash is a
139- # regular name character in the object namespace.
140- # * '\\?\c:\foo/bar' is invalid because '/' is illegal in NT filesystems.
141- # The only path separator at the filesystem level is backslash.
142- # * '//?/c:\a' and '//?/c:/a' are effectively equivalent to '\\.\c:\a' and
143- # thus limited to MAX_PATH.
144- # * Prior to Windows 8, ANSI API bytes paths are limited to MAX_PATH,
145- # even with the '\\?\' prefix.
146-
147129 def splitroot (self , part , sep = sep ):
148- first = part [0 :1 ]
149- second = part [1 :2 ]
150- if (second == sep and first == sep ):
151- # XXX extended paths should also disable the collapsing of "."
152- # components (according to MSDN docs).
153- prefix , part = self ._split_extended_path (part )
154- first = part [0 :1 ]
155- second = part [1 :2 ]
130+ drv , rest = self .pathmod .splitdrive (part )
131+ if drv [:1 ] == sep or rest [:1 ] == sep :
132+ return drv , sep , rest .lstrip (sep )
156133 else :
157- prefix = ''
158- third = part [2 :3 ]
159- if (second == sep and first == sep and third != sep ):
160- # is a UNC path:
161- # vvvvvvvvvvvvvvvvvvvvv root
162- # \\machine\mountpoint\directory\etc\...
163- # directory ^^^^^^^^^^^^^^
164- index = part .find (sep , 2 )
165- if index != - 1 :
166- index2 = part .find (sep , index + 1 )
167- # a UNC path can't have two slashes in a row
168- # (after the initial two)
169- if index2 != index + 1 :
170- if index2 == - 1 :
171- index2 = len (part )
172- if prefix :
173- return prefix + part [1 :index2 ], sep , part [index2 + 1 :]
174- else :
175- return part [:index2 ], sep , part [index2 + 1 :]
176- drv = root = ''
177- if second == ':' and first in self .drive_letters :
178- drv = part [:2 ]
179- part = part [2 :]
180- first = third
181- if first == sep :
182- root = first
183- part = part .lstrip (sep )
184- return prefix + drv , root , part
134+ return drv , '' , rest
185135
186136 def casefold (self , s ):
187137 return s .lower ()
@@ -192,16 +142,6 @@ def casefold_parts(self, parts):
192142 def compile_pattern (self , pattern ):
193143 return re .compile (fnmatch .translate (pattern ), re .IGNORECASE ).fullmatch
194144
195- def _split_extended_path (self , s , ext_prefix = ext_namespace_prefix ):
196- prefix = ''
197- if s .startswith (ext_prefix ):
198- prefix = s [:4 ]
199- s = s [4 :]
200- if s .startswith ('UNC\\ ' ):
201- prefix += s [:3 ]
202- s = '\\ ' + s [3 :]
203- return prefix , s
204-
205145 def is_reserved (self , parts ):
206146 # NOTE: the rules for reserved names seem somewhat complicated
207147 # (e.g. r"..\NUL" is reserved but not r"foo\NUL" if "foo" does not
0 commit comments