##// END OF EJS Templates
posix: add extended support for OS X path folding...
Matt Mackall -
r15551:1fa41d1f stable
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import os, sys, errno, stat, getpass, pwd, grp, tempfile
9 import os, sys, errno, stat, getpass, pwd, grp, tempfile, unicodedata
10
10
11 posixfile = open
11 posixfile = open
12 nulldev = '/dev/null'
12 nulldev = '/dev/null'
@@ -170,6 +170,24 b' def normcase(path):'
170
170
171 if sys.platform == 'darwin':
171 if sys.platform == 'darwin':
172 import fcntl # only needed on darwin, missing on jython
172 import fcntl # only needed on darwin, missing on jython
173
174 def normcase(path):
175 try:
176 u = path.decode('utf-8')
177 except UnicodeDecodeError:
178 # percent-encode any characters that don't round-trip
179 p2 = path.decode('utf-8', 'replace').encode('utf-8')
180 s = ""
181 for a, b in zip(path, p2):
182 if a != b:
183 s += "%%%02X" % ord(a)
184 else:
185 s += a
186 u = s.decode('utf-8')
187
188 # Decompose then lowercase (HFS+ technote specifies lower)
189 return unicodedata.normalize('NFD', u).lower().encode('utf-8')
190
173 def realpath(path):
191 def realpath(path):
174 '''
192 '''
175 Returns the true, canonical file system path equivalent to the given
193 Returns the true, canonical file system path equivalent to the given
General Comments 0
You need to be logged in to leave comments. Login now