@@ -120,9 +120,6 @@ class _WindowsFlavour(_Flavour):
120
120
121
121
is_supported = (os .name == 'nt' )
122
122
123
- drive_letters = set ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )
124
- ext_namespace_prefix = '\\ \\ ?\\ '
125
-
126
123
reserved_names = (
127
124
{'CON' , 'PRN' , 'AUX' , 'NUL' , 'CONIN$' , 'CONOUT$' } |
128
125
{'COM%s' % c for c in '123456789\xb9 \xb2 \xb3 ' } |
@@ -145,43 +142,11 @@ class _WindowsFlavour(_Flavour):
145
142
# even with the '\\?\' prefix.
146
143
147
144
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 ]
145
+ drv , rest = self .pathmod .splitdrive (part )
146
+ if drv [:1 ] == sep or rest [:1 ] == sep :
147
+ return drv , sep , rest .lstrip (sep )
156
148
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
149
+ return drv , '' , rest
185
150
186
151
def casefold (self , s ):
187
152
return s .lower ()
@@ -192,16 +157,6 @@ def casefold_parts(self, parts):
192
157
def compile_pattern (self , pattern ):
193
158
return re .compile (fnmatch .translate (pattern ), re .IGNORECASE ).fullmatch
194
159
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
-
205
160
def is_reserved (self , parts ):
206
161
# NOTE: the rules for reserved names seem somewhat complicated
207
162
# (e.g. r"..\NUL" is reserved but not r"foo\NUL" if "foo" does not
0 commit comments