##// END OF EJS Templates
util: remove unused realpath (issue4063)...
Christian Ebert -
r20202:a6014018 default
parent child Browse files
Show More
@@ -197,7 +197,6 b' def normcase(path):'
197 197 return path.lower()
198 198
199 199 if sys.platform == 'darwin':
200 import fcntl # only needed on darwin, missing on jython
201 200
202 201 def normcase(path):
203 202 '''
@@ -265,51 +264,6 b" if sys.platform == 'darwin':"
265 264 # Decompose then lowercase (HFS+ technote specifies lower)
266 265 return unicodedata.normalize('NFD', u).lower().encode('utf-8')
267 266
268 def realpath(path):
269 '''
270 Returns the true, canonical file system path equivalent to the given
271 path.
272
273 Equivalent means, in this case, resulting in the same, unique
274 file system link to the path. Every file system entry, whether a file,
275 directory, hard link or symbolic link or special, will have a single
276 path preferred by the system, but may allow multiple, differing path
277 lookups to point to it.
278
279 Most regular UNIX file systems only allow a file system entry to be
280 looked up by its distinct path. Obviously, this does not apply to case
281 insensitive file systems, whether case preserving or not. The most
282 complex issue to deal with is file systems transparently reencoding the
283 path, such as the non-standard Unicode normalisation required for HFS+
284 and HFSX.
285 '''
286 # Constants copied from /usr/include/sys/fcntl.h
287 F_GETPATH = 50
288 O_SYMLINK = 0x200000
289
290 try:
291 fd = os.open(path, O_SYMLINK)
292 except OSError, err:
293 if err.errno == errno.ENOENT:
294 return path
295 raise
296
297 try:
298 return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0')
299 finally:
300 os.close(fd)
301 elif sys.version_info < (2, 4, 2, 'final'):
302 # Workaround for http://bugs.python.org/issue1213894 (os.path.realpath
303 # didn't resolve symlinks that were the first component of the path.)
304 def realpath(path):
305 if os.path.isabs(path):
306 return os.path.realpath(path)
307 else:
308 return os.path.realpath('./' + path)
309 else:
310 # Fallback to the likely inadequate Python builtin function.
311 realpath = os.path.realpath
312
313 267 if sys.platform == 'cygwin':
314 268 # workaround for cygwin, in which mount point part of path is
315 269 # treated as case sensitive, even though underlying NTFS is case
@@ -52,7 +52,6 b' pconvert = platform.pconvert'
52 52 popen = platform.popen
53 53 posixfile = platform.posixfile
54 54 quotecommand = platform.quotecommand
55 realpath = platform.realpath
56 55 rename = platform.rename
57 56 samedevice = platform.samedevice
58 57 samefile = platform.samefile
@@ -133,15 +133,6 b' def normpath(path):'
133 133 def normcase(path):
134 134 return encoding.upper(path)
135 135
136 def realpath(path):
137 '''
138 Returns the true, canonical file system path equivalent to the given
139 path.
140 '''
141 # TODO: There may be a more clever way to do this that also handles other,
142 # less common file systems.
143 return os.path.normpath(normcase(os.path.realpath(path)))
144
145 136 def samestat(s1, s2):
146 137 return False
147 138
General Comments 0
You need to be logged in to leave comments. Login now