/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Alexander Belchenko
  • Date: 2007-02-14 10:09:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2289.
  • Revision ID: bialix@ukr.net-20070214100900-i4rygckilzdjc1tz
Reimplementation of ntpath.abspath in Python for Windows98: unicode safe, UNC path safe

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
    return _win32_fixdrive(_nt_abspath(unicode(path)).replace('\\', '/'))
260
260
 
261
261
 
 
262
def _win98_abspath(path):
 
263
    """Return the absolute version of a path.
 
264
    Windows 98 safe implementation (python reimplementation
 
265
    of Win32 API function GetFullPathNameW)
 
266
    """
 
267
    # Corner cases:
 
268
    #   C:\path     => C:/path
 
269
    #   C:/path     => C:/path
 
270
    #   \\HOST\path => //HOST/path
 
271
    #   //HOST/path => //HOST/path
 
272
    #   path        => C:/cwd/path
 
273
    #   /path       => C:/path
 
274
    path = unicode(path)
 
275
    # check for absolute path
 
276
    drive = _nt_splitdrive(path)[0]
 
277
    if drive == '' and path[:2] not in('//','\\\\'):
 
278
        cwd = os.getcwdu()
 
279
        # we cannot simply os.path.join cwd and path
 
280
        # because os.path.join('C:','/path') produce '/path'
 
281
        # and this is incorrect
 
282
        if path[:1] in ('/','\\'):
 
283
            cwd = _nt_splitdrive(cwd)[0]
 
284
        path = cwd + '\\' + path
 
285
    return _win32_fixdrive(_nt_normpath(path).replace('\\', '/'))
 
286
 
 
287
if win32utils.winver == 'Windows 98':
 
288
    _win32_abspath = _win98_abspath
 
289
 
 
290
 
262
291
def _win32_realpath(path):
263
292
    # Real _nt_realpath doesn't have a problem with a unicode cwd
264
293
    return _win32_fixdrive(_nt_realpath(unicode(path)).replace('\\', '/'))