Ticket #150: os2knixpath.py.diff

File os2knixpath.py.diff, 1.5 KB (added by dmik, 9 years ago)
  • os2knixpath.py

    old new  
    1919           "splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
    2020           "extsep","devnull","realpath","supports_unicode_filenames"]
    2121
     22_unixroot = os.environ.get('UNIXROOT')
     23
    2224# strings representing various path-related bits and pieces
    2325curdir = '.'
    2426pardir = '..'
     
    2628sep = '/'
    2729altsep = '\\'
    2830pathsep = ';'
    29 defpath = '.;' + (os.environ['UNIXROOT'] + '\\usr\\bin' if 'UNIXROOT' in os.environ else 'C:\\bin')
     31defpath = '.;' + (_unixroot.replace(sep, altsep) + '\\usr\\bin' if _unixroot else 'C:\\bin')
    3032devnull = 'nul'
    3133
     34_unixroot_normcase = _unixroot.replace(altsep, sep).lower()
     35
    3236# Normalize the case of a pathname and map slashes to backslashes.
    3337# Other normalizations (such as optimizing '../' away) are not done
    3438# (this is done by normpath).
     
    3640def normcase(s):
    3741    """Normalize case of pathname.
    3842
    39     Makes all characters lowercase and all altseps into seps."""
    40     return s.replace(altsep, sep).lower()
     43    Makes all characters lowercase and all altseps into seps.
    4144
     45    Also, if the string starts with os.environ['UNIXROOT'], this part
     46    will be replaced with '/@unixroot' to ensure portability of the
     47    returned path across different installations."""
     48    s = s.replace(altsep, sep).lower()
     49    if _unixroot:
     50        s = s.replace(_unixroot_normcase, '/@unixroot')
     51    return s
    4252
    4353# Join two (or more) paths.
    4454