Browse Source

BZ 65499 avoid getCanonicalFile in many cases

master
Stefan Bodewig 3 years ago
parent
commit
4da6c49b04
2 changed files with 15 additions and 2 deletions
  1. +2
    -0
      WHATSNEW
  2. +13
    -2
      src/main/org/apache/tools/ant/util/FileUtils.java

+ 2
- 0
WHATSNEW View File

@@ -19,6 +19,8 @@ Other changes:
* AntClassLoader now implements the ClassLoader#findResource(String) method.
Github Pull Request #150

* Ant tries to avoid file name canonicalization whne possible.
Bugzilla Report 65499

Changes from Ant 1.10.10 TO Ant 1.10.11
=======================================


+ 13
- 2
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -1421,10 +1421,21 @@ public class FileUtils {
if (f1 == null || f2 == null) {
return false;
}
return fileNameEquals(f1, f2) || isSameFile(f1, f2);
}

private boolean isSameFile(File f1, File f2) throws IOException {
if (f1.exists()) {
try {
return f2.exists() && Files.isSameFile(f1.toPath(), f2.toPath());
} catch (NoSuchFileException e) {
// file has been removed between exists check and isSameFile?
return false;
}
}
File f1Normalized = normalize(f1.getAbsolutePath());
File f2Normalized = normalize(f2.getAbsolutePath());
return f1Normalized.equals(f2Normalized)
|| f1Normalized.getCanonicalFile().equals(f2Normalized
return f1Normalized.getCanonicalFile().equals(f2Normalized
.getCanonicalFile());
}



Loading…
Cancel
Save