equal
deleted
inserted
replaced
322 elif name == root: |
322 elif name == root: |
323 return '' |
323 return '' |
324 else: |
324 else: |
325 # Determine whether `name' is in the hierarchy at or beneath `root', |
325 # Determine whether `name' is in the hierarchy at or beneath `root', |
326 # by iterating name=dirname(name) until that causes no change (can't |
326 # by iterating name=dirname(name) until that causes no change (can't |
327 # check name == '/', because that doesn't work on windows). For each |
327 # check name == '/', because that doesn't work on windows). The list |
328 # `name', compare dev/inode numbers. If they match, the list `rel' |
328 # `rel' holds the reversed list of components making up the relative |
329 # holds the reversed list of components making up the relative file |
329 # file name we want. |
330 # name we want. |
|
331 root_st = os.stat(root) |
|
332 rel = [] |
330 rel = [] |
333 while True: |
331 while True: |
334 try: |
332 try: |
335 name_st = os.stat(name) |
333 s = util.samefile(name, root) |
336 except OSError: |
334 except OSError: |
337 name_st = None |
335 s = False |
338 if name_st and util.samestat(name_st, root_st): |
336 if s: |
339 if not rel: |
337 if not rel: |
340 # name was actually the same as root (maybe a symlink) |
338 # name was actually the same as root (maybe a symlink) |
341 return '' |
339 return '' |
342 rel.reverse() |
340 rel.reverse() |
343 name = os.path.join(*rel) |
341 name = os.path.join(*rel) |