eryksun added the comment:
> 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")
1
>>> gfpn = os.path._getfinalpathname
>>> gfpn(r'\\?\C:foo')
'\\\\?\\C:\\Python34'
>>> 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:\\')
'\\\\?\\C:\\'
>>> gfpn('\\\\?\\GLOBALROOT\\Device\\HarddiskVolume1\\')
'\\\\?\\C:\\'
>>> gfpn(r'\\?\GLOBALROOT\SystemRoot')
'\\\\?\\C:\\Windows'
>>> p = r'\\?\GLOBALROOT\Sessions\0\DosDevices\00000000-0f341de9\C:foo'
>>> gfpn(p)
'\\\\?\\C:\\Python34'
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)
3
>>> buf.value
'C:\\'
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22299>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com