0

In Python, the u'\\\\?\\' syntax can be used to access long filenames on Windows as mentioned here. However, this doesn't work on network shares that don't begin with a drive-letter. Is there a workaround to make this work on a network share, that is smarter than our existing approaches?

Working but non-ideal approaches are

  • Copying files locally and use the magic syntax
  • Auto mount/unmount network share, use magic syntax
Community
  • 1
  • 1
Dschoni
  • 3,714
  • 6
  • 45
  • 80
  • 1
    See http://stackoverflow.com/a/31474059/7441757 – Roelant Mar 20 '17 at 14:43
  • 1
    Note that the prefix is `u'\\\\?\\'`, not `u'//?/'`. The system looks for this precise prefix, in which case it bypasses normal path processing. The device for UNC paths is `UNC`, e.g. `u'\\\\?\\UNC\\server\\share\\path'`. It's implemented as an object symbolic link to the real native device for the Multiple UNC Provider, `\Device\Mup`. – Eryk Sun Mar 20 '17 at 14:49
  • You could also (but shouldn't in practice) use the link to root of the object tree to bypass this layer of abstraction, e.g. `u'\\\\?\\GlobalRoot\\Device\\Mup\\server\\share\\path'`. – Eryk Sun Mar 20 '17 at 15:35
  • The system finds these object links in one of two places. It first checks your logon session's DOS devices under `\Sessions\0\DosDevices\[LogonSessionId]`, and then it checks the system links under `\Global??`, e.g. `\Global??\C:` or `\Global??\GlobalRoot`. – Eryk Sun Mar 20 '17 at 15:39
  • This object tree is used for all named objects in Windows, but the API abstracts it away for various reasons, such as by using the `HKLM` predefined handle for `\Registry\Machine`. Some of these links, such as `\Global??\UNC`, are create by the session manager (smss.exe) according to the values in the key `HKLM\System\CurrentControlSet\Control\Session Manager\DOS Devices`. But DOS drive letters (e.g. `C:` => `\Device\HarddiskVolume2`) and GUID mount points are maintained by the MountPoint manager, which persists the symbolic links by volume ID under `HKLM\System\MountedDevices`. – Eryk Sun Mar 20 '17 at 15:49

0 Answers0