copyFile(File, File) checked source.exists() before its symbolic-link branch, and File.exists() follows links, so a link whose target is missing was rejected as a missing file. The link branch now runs first. Two smaller gaps in the same path surfaced while testing: the link branch did not create the destination directory the way the regular-file path does, and the filtering overload then tried to copy POSIX permissions onto a dangling link, which follows the link and fails. Both are handled in this change.
The two tests follow the scenarios from #110 by @kwin: a dangling link, and a relative link copied into another directory where its target does not resolve. Both are skipped on Windows like the other symlink tests here.
copyFile is deprecated in favour of Files.copy with NOFOLLOW_LINKS, but it still ships, and maven-filtering hit this same path in MSHARED-1112, so the reordered check is worth having.
Fixes #306.
Verified: mvn -B verify on JDK 17 -> Tests run: 793, Failures: 0, Errors: 0; on master the dangling-link test fails with IOException: File .../dangling does not exist.
This change was created with AI assistance.