Skip to content

Commit e5d2ecd

Browse files
author
Gary Gregory
committed
Revert "AccumulatorPathVisitor does not track directories properly."
This reverts commit b970553.
1 parent b970553 commit e5d2ecd

3 files changed

Lines changed: 4 additions & 117 deletions

File tree

src/changes/changes.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ The <action> type attribute can be add,update,fix,remove.
6363
<action dev="ggregory" type="fix" due-to="Michiel Kalkman">
6464
FileUtils#copyDirectory(File, File, FileFilter, preserveFileDate) clean up #163.
6565
</action>
66-
<action dev="ggregory" type="fix" due-to="Michiel Kalkman">
67-
AccumulatorPathVisitor does not track directories properly.
68-
</action>
6966
<!-- ADD -->
7067
<action dev="ggregory" type="add" due-to="Gary Gregory">
7168
Add FileSystemProviders class.

src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.IOException;
2121
import java.nio.file.FileVisitResult;
22+
import java.nio.file.Files;
2223
import java.nio.file.Path;
2324
import java.nio.file.attribute.BasicFileAttributes;
2425
import java.util.ArrayList;
@@ -69,10 +70,6 @@ public AccumulatorPathVisitor(final PathCounters pathCounter) {
6970
super(pathCounter);
7071
}
7172

72-
private void add(final List<Path> list, final Path dir) {
73-
list.add(dir.normalize());
74-
}
75-
7673
@Override
7774
public boolean equals(final Object obj) {
7875
if (this == obj) {
@@ -114,12 +111,6 @@ public int hashCode() {
114111
return result;
115112
}
116113

117-
@Override
118-
public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
119-
add(dirList, dir);
120-
return super.postVisitDirectory(dir, exc);
121-
}
122-
123114
/**
124115
* Relativizes each directory path with {@link Path#relativize(Path)} against the given {@code parent}, optionally
125116
* sorting the result.
@@ -129,8 +120,7 @@ public FileVisitResult postVisitDirectory(final Path dir, final IOException exc)
129120
* @param comparator How to sort, null uses default sorting.
130121
* @return A new list
131122
*/
132-
public List<Path> relativizeDirectories(final Path parent, final boolean sort,
133-
final Comparator<? super Path> comparator) {
123+
public List<Path> relativizeDirectories(final Path parent, final boolean sort, final Comparator<? super Path> comparator) {
134124
return PathUtils.relativize(getDirList(), parent, sort, comparator);
135125
}
136126

@@ -143,14 +133,13 @@ public List<Path> relativizeDirectories(final Path parent, final boolean sort,
143133
* @param comparator How to sort, null uses default sorting.
144134
* @return A new list
145135
*/
146-
public List<Path> relativizeFiles(final Path parent, final boolean sort,
147-
final Comparator<? super Path> comparator) {
136+
public List<Path> relativizeFiles(final Path parent, final boolean sort, final Comparator<? super Path> comparator) {
148137
return PathUtils.relativize(getFileList(), parent, sort, comparator);
149138
}
150139

151140
@Override
152141
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attributes) throws IOException {
153-
add(fileList, file);
142+
((Files.isDirectory(file)) ? dirList : fileList).add(file.normalize());
154143
return super.visitFile(file, attributes);
155144
}
156145

src/test/java/org/apache/commons/io/file/AccumulatorPathVisitorTest.java

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

0 commit comments

Comments
 (0)