On Wed, 17 Sep 2025 00:32:37 GMT, Brian Burkhalter <[email protected]> wrote:

>> `File.getCanonicalPath` invokes `GetFinalPathNameByHandle` on the result of 
>> `canonicalize0` which causes the drive letter of a mapped drive to be 
>> converted to a UNC prefix. If such a substitution is detected, this request 
>> proposes to revert the conversion of drive letter to UNC prefix before 
>> returning the canonical path.
>
> Brian Burkhalter has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8355342: Corrected a comment

>> Would it be possible to provide a summary as to why we don't run into this 
>> with toRealPath?

> In `toRealPath`, the function `GetFinalPathNameByHandle` is not invoked 
> unless links are being followed and a reparse point is encountered.

In this scenario

 Directory of Z:\

09/17/2025  03:39 PM    <DIR>          .
09/17/2025  08:36 AM    <SYMLINK>      link [target.txt]
09/10/2025  04:41 PM                18 target.txt

where `Z:` is mapped as `net use Z: \\localhost\c$\Temp`, in other words to 
`C:\Temp`, a similar problem happens with `toRealPath`:

jshell> Path.of("Z:\\target.txt").toRealPath()
$7 ==> Z:\target.txt

jshell> Path.of("Z:\\link").toRealPath()
$8 ==> \\localhost\c$\Temp\target.txt

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27324#issuecomment-3304816136

Reply via email to