~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-15 12:40:16 UTC
  • mfrom: (2279.4.4 win98.support)
  • Revision ID: pqm@pqm.ubuntu.com-20070215124016-39cb7bf4759aeede
(bialix) custom reimplementation of abspath in Python for Windows
 98 (#84278)

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 = path[1:]
 
285
        path = cwd + '\\' + path
 
286
    return _win32_fixdrive(_nt_normpath(path).replace('\\', '/'))
 
287
 
 
288
if win32utils.winver == 'Windows 98':
 
289
    _win32_abspath = _win98_abspath
 
290
 
 
291
 
262
292
def _win32_realpath(path):
263
293
    # Real _nt_realpath doesn't have a problem with a unicode cwd
264
294
    return _win32_fixdrive(_nt_realpath(unicode(path)).replace('\\', '/'))