Author eryksun
Recipients eryksun, nsiregar, paul.moore, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Date 2021-04-07.00:26:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617755199.88.0.780939912272.issue37609@roundup.psfhosted.org>
In-reply-to
Content
> I've got a fairly simple implementation for this using the (new) 
> nt._path_splitroot native method

It's for the best to let the system path API handle this, especially if doing so gets this issue resolved, as well as others like it and those that depend on it. I'm a bit disappointed, however, that PathCchSkipRoot() doesn't handle some of the cases that I handled in splitdrive.py. 

PathCchSkipRoot() doesn't support the "Global" link in device paths. Fortunately this case is uncommon. In practice "Global" is only needed when a DOS device name has to be created globally, e.g. "\\.\Global\SomeGlobalDevice".

PathCchSkipRoot() splits "\\.\UNC\server\share" as "\\.\UNC\" and "server\share", but that's okay since no one uses "\\.\UNC". 

PathCchSkipRoot() restricts the "\\?\" prefix to drive names, volume GUID names, and the "UNC" device -- such as "\\?\X:", "\\?\Volume{12345678-1234-1234-1234-123456789ABC}", and "\\?\UNC\server\share". Other device names such as the "PIPE" device have to use the "\\.\" prefix. Rarely, a device path may need "\\?\" if it's a long path or needs to bypass normalization. I wanted splitdrive() to remain neutral for such cases, but that will have to be sacrificed.

PathCchSkipRoot() doesn't ignore repeated slashes in the drive part of a UNC "\\server\share" or "\\?\UNC\server\share" path, even though GetFullPathNameW() collapses all but the initial two slashes. (More than two initial slashes is invalid.) For example, the system normalizes "//localhost///C$" as "\\localhost\C$:

    >>> os.chdir('//localhost///C$/Temp')
    >>> print(os.getcwd())
    \\localhost\C$\Temp

PathCchSkipRoot() also allows just a UNC server to count as a root, e.g. "\\server" or "\\?\UNC\server", though a valid UNC path requires a share name. Without a share, FindFirstFileW(L"//server/*", &find_data) will fail to parse the directory name correctly and try to open "//server/*", which is an invalid name. If splitdrive() requires a valid drive name, it should not return "//server" or "//server/" as a drive name.
History
Date User Action Args
2021-04-07 00:26:39eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, serhiy.storchaka, steve.dower, nsiregar
2021-04-07 00:26:39eryksunsetmessageid: <1617755199.88.0.780939912272.issue37609@roundup.psfhosted.org>
2021-04-07 00:26:39eryksunlinkissue37609 messages
2021-04-07 00:26:39eryksuncreate