If one has for example
$ ls -l link ~/TheTarget
-rw-r--r-- 1 bpb staff 0 Oct 19 10:49 /Users/bpb/TheTarget
lrwxr-xr-x 1 bpb staff 10 Oct 19 10:48 link@ -> /Users/bpb
and one calls Path.of("link/thetarget").toRealPath() the result is
/Users/bpb/TheTarget
but if one calls Path.of("link/thetarget").toRealPath(NOFOLLOW_LINKS) the result it
/Users/bpb/dev/bugs/jdk/Path-toRealPath/link/thetarget
In the latter result the retained case of "thetarget" is not obtained. This appears to be because realpath(3) is used when links are followed, but if they are not followed then the code goes down the hierarchy and the case is not preserved. This example is on APFS.
$ ls -l link ~/TheTarget
-rw-r--r-- 1 bpb staff 0 Oct 19 10:49 /Users/bpb/TheTarget
lrwxr-xr-x 1 bpb staff 10 Oct 19 10:48 link@ -> /Users/bpb
and one calls Path.of("link/thetarget").toRealPath() the result is
/Users/bpb/TheTarget
but if one calls Path.of("link/thetarget").toRealPath(NOFOLLOW_LINKS) the result it
/Users/bpb/dev/bugs/jdk/Path-toRealPath/link/thetarget
In the latter result the retained case of "thetarget" is not obtained. This appears to be because realpath(3) is used when links are followed, but if they are not followed then the code goes down the hierarchy and the case is not preserved. This example is on APFS.
- duplicates
-
JDK-8069337 (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) produces unexpected result (OS X)
-
- Closed
-
- relates to
-
JDK-8295543 DocTrees.getElement returns a package when none is expected or defined
-
- Open
-
-
JDK-8308678 (fs) UnixPath::toRealPath needs additional permissions when running with SM (macOS)
-
- Closed
-