Show More
@@ -118,9 +118,9 b' def _buildlowerencodefun():' | |||
|
118 | 118 | |
|
119 | 119 | lowerencode = _buildlowerencodefun() |
|
120 | 120 | |
|
121 | _winreservednames = '''con prn aux nul | |
|
122 | com1 com2 com3 com4 com5 com6 com7 com8 com9 | |
|
123 | lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() | |
|
121 | # Windows reserved names: con, prn, aux, nul, com1..com9, lpt1..lpt9 | |
|
122 | _winres3 = ('aux', 'con', 'prn', 'nul') # length 3 | |
|
123 | _winres4 = ('com', 'lpt') # length 4 (with trailing 1..9) | |
|
124 | 124 | def _auxencode(path, dotencode): |
|
125 | 125 | ''' |
|
126 | 126 | Encodes filenames containing names reserved by Windows or which end in |
@@ -144,16 +144,21 b' def _auxencode(path, dotencode):' | |||
|
144 | 144 | res = [] |
|
145 | 145 | for n in path.split('/'): |
|
146 | 146 | if n: |
|
147 | base = n.split('.')[0] | |
|
148 | if base and (base in _winreservednames): | |
|
147 | if dotencode and n[0] in '. ': | |
|
148 | n = "~%02x" % ord(n[0]) + n[1:] | |
|
149 | else: | |
|
150 | l = n.find('.') | |
|
151 | if l == -1: | |
|
152 | l = len(n) | |
|
153 | if ((l == 3 and n[:3] in _winres3) or | |
|
154 | (l == 4 and n[3] <= '9' and n[3] >= '1' | |
|
155 | and n[:3] in _winres4)): | |
|
149 | 156 | # encode third letter ('aux' -> 'au~78') |
|
150 | 157 | ec = "~%02x" % ord(n[2]) |
|
151 | 158 | n = n[0:2] + ec + n[3:] |
|
152 | 159 | if n[-1] in '. ': |
|
153 | 160 | # encode last period or space ('foo...' -> 'foo..~2e') |
|
154 | 161 | n = n[:-1] + "~%02x" % ord(n[-1]) |
|
155 | if dotencode and n[0] in '. ': | |
|
156 | n = "~%02x" % ord(n[0]) + n[1:] | |
|
157 | 162 | res.append(n) |
|
158 | 163 | return '/'.join(res) |
|
159 | 164 |
General Comments 0
You need to be logged in to leave comments.
Login now