Skip to content

Commit 9d43212

Browse files
IO-514: Remove org.apache.commons.io.Java7Support
1 parent 948e027 commit 9d43212

4 files changed

Lines changed: 5 additions & 294 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ The <action> type attribute can be add,update,fix,remove.
8383
<action issue="IO-519" dev="jochen" type="add">
8484
Add MessageDigestCalculatingInputStream
8585
</action>
86+
<action issue="IO-514" dev="pschumacher" type="remove">
87+
Remove org.apache.commons.io.Java7Support
88+
</action>
8689
</release>
8790
<release version="2.5" date="2016-04-22" description="New features and bug fixes.">
8891
<action issue="IO-492" dev="ggregory" type="fix" due-to="Santiago Castro">

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.nio.channels.FileChannel;
3535
import java.nio.charset.Charset;
3636
import java.nio.charset.StandardCharsets;
37+
import java.nio.file.Files;
3738
import java.util.ArrayList;
3839
import java.util.Collection;
3940
import java.util.Date;
@@ -3029,61 +3030,9 @@ public static void moveToDirectory(final File src, final File destDir, final boo
30293030
* @since 2.0
30303031
*/
30313032
public static boolean isSymlink(final File file) throws IOException {
3032-
if ( Java7Support.isAtLeastJava7() )
3033-
{
3034-
return Java7Support.isSymLink( file );
3035-
}
3036-
30373033
if (file == null) {
30383034
throw new NullPointerException("File must not be null");
30393035
}
3040-
if (FilenameUtils.isSystemWindows()) {
3041-
return false;
3042-
}
3043-
File fileInCanonicalDir = null;
3044-
if (file.getParent() == null) {
3045-
fileInCanonicalDir = file;
3046-
} else {
3047-
final File canonicalDir = file.getParentFile().getCanonicalFile();
3048-
fileInCanonicalDir = new File(canonicalDir, file.getName());
3049-
}
3050-
3051-
if (fileInCanonicalDir.getCanonicalFile().equals(fileInCanonicalDir.getAbsoluteFile())) {
3052-
return isBrokenSymlink(file);
3053-
} else {
3054-
return true;
3055-
}
3056-
}
3057-
3058-
/**
3059-
* Determines if the specified file is possibly a broken symbolic link.
3060-
*
3061-
* @param file the file to check
3062-
3063-
* @return true if the file is a Symbolic Link
3064-
* @throws IOException if an IO error occurs while checking the file
3065-
*/
3066-
private static boolean isBrokenSymlink(final File file) throws IOException {
3067-
// if file exists then if it is a symlink it's not broken
3068-
if (file.exists()) {
3069-
return false;
3070-
}
3071-
// a broken symlink will show up in the list of files of its parent directory
3072-
final File canon = file.getCanonicalFile();
3073-
File parentDir = canon.getParentFile();
3074-
if (parentDir == null || !parentDir.exists()) {
3075-
return false;
3076-
}
3077-
3078-
// is it worthwhile to create a FileFilterUtil method for this?
3079-
// is it worthwhile to create an "identity" IOFileFilter for this?
3080-
File[] fileInDir = parentDir.listFiles(
3081-
new FileFilter() {
3082-
public boolean accept(File aFile) {
3083-
return aFile.equals(canon);
3084-
}
3085-
}
3086-
);
3087-
return fileInDir != null && fileInDir.length > 0;
3036+
return Files.isSymbolicLink(file.toPath());
30883037
}
30893038
}

src/main/java/org/apache/commons/io/Java7Support.java

Lines changed: 0 additions & 184 deletions
This file was deleted.

src/test/java/org/apache/commons/io/Java7SupportTest.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)