Author eryksun
Recipients Kevin.Norris, eryksun, pitrou, steve.dower, tim.golden, zach.ware
Date 2014-09-07.18:03:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> If you take "//?/C:/" and join it with e.g. "foo", you get an 
> absolute path (or, if you remove the drive's trailing slash, you 
> get something that's invalid AFAIK).

FYI, DOS device names such as "C:" are NT symlinks. Win32 looks for DOS device links in NT's \Global?? directory, and also per logon-session in \Sessions\0\DosDevices\LOGON_ID. 

A link named "C:foo" is actually possible:

    >>> windll.kernel32.DefineDosDeviceW(0, "C:foo", "C:\\Python34")
    >>> gfpn = os.path._getfinalpathname
    >>> gfpn(r'\\?\C:foo')
    >>> os.listdir(r'\\?\C:foo')
    ['DLLs', 'Doc', 'include', 'Lib', 'libs', 'LICENSE.txt', 'NEWS.txt', 'python.exe', 'pythonw.exe', 'README.txt', 'Scripts', 'tcl', 'Tools']

GLOBALROOT links to the native NT root:

    >>> gfpn('\\\\?\\GLOBALROOT\\Global??\C:\\')
    >>> gfpn('\\\\?\\GLOBALROOT\\Device\\HarddiskVolume1\\')   
    >>> gfpn(r'\\?\GLOBALROOT\SystemRoot') 
    >>> p = r'\\?\GLOBALROOT\Sessions\0\DosDevices\00000000-0f341de9\C:foo'        
    >>> gfpn(p)

Without the \\?\ prefix, "C:foo" is relative to the current directory on the C: drive:

    >>> os.chdir('C:\\')
    >>> os.mkdir('foo')
    >>> os.listdir('C:foo')

where the current directory on C: is stored in the "=C:" environment variable:

    >>> buf = (c_wchar * 100)()                
    >>> windll.kernel32.GetEnvironmentVariableW("=C:", buf)
    >>> buf.value
Date User Action Args
2014-09-07 18:03:52eryksunsetrecipients: + eryksun, pitrou, tim.golden, zach.ware, steve.dower, Kevin.Norris
2014-09-07 18:03:52eryksunsetmessageid: <>
2014-09-07 18:03:52eryksunlinkissue22299 messages
2014-09-07 18:03:51eryksuncreate