Path#relative_to?
across equivalent Windows roots
#15591
Labels
platform:windows
Windows support based on the MSVC toolchain / Win32 API
status:discussion
topic:stdlib:files
Path#relative_to?
requires both the target and the base paths to have the exactly same anchor, otherwisenil
is returned. It might be surprising to some that alternative Windows directory separators are not considered:Resolving this part is relatively easy; as long as the drive letters are identical, it should not matter which slash is used.
The complicated part arises when dealing with local device paths (#15590), because either the target or base can start with
\\.
, and it could be equivalent to some other normal or UNC path:These can be done purely lexically, without any filesystem access. So I wonder if
Path#relative_to?
should take care of these cases as well.The text was updated successfully, but these errors were encountered: