-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added PathVisitorFileFilterTest - ternaryop and line number fix (#208)
Co-authored-by: nbauma109 <nbauma109@github.com>
- Loading branch information
Showing
5 changed files
with
144 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package jd.core.test; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.junit.Test; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class PathVisitorFileFilterTest extends AbstractTestCase { | ||
@Test | ||
public void test() throws Exception { | ||
String output = decompile("org/apache/commons/io/filefilter/PathVisitorFileFilter"); | ||
assertEquals(IOUtils.toString(getClass().getResource("PathVisitorFileFilter.txt"), StandardCharsets.UTF_8), output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* */ package org.apache.commons.io.filefilter; | ||
/* */ | ||
/* */ import java.io.File; | ||
/* */ import java.io.IOException; | ||
/* */ import java.nio.file.FileVisitResult; | ||
/* */ import java.nio.file.Files; | ||
/* */ import java.nio.file.LinkOption; | ||
/* */ import java.nio.file.Path; | ||
/* */ import java.nio.file.attribute.BasicFileAttributes; | ||
/* */ import org.apache.commons.io.file.NoopPathVisitor; | ||
/* */ import org.apache.commons.io.file.PathUtils; | ||
/* */ import org.apache.commons.io.file.PathVisitor; | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
/* */ public class PathVisitorFileFilter | ||
/* */ extends AbstractFileFilter | ||
/* */ { | ||
/* */ private final PathVisitor pathVisitor; | ||
/* */ | ||
/* */ public PathVisitorFileFilter(PathVisitor pathVisitor) | ||
/* */ { | ||
/* 46 */ this.pathVisitor = (pathVisitor == null ? NoopPathVisitor.INSTANCE : pathVisitor); | ||
/* */ } | ||
/* */ | ||
/* */ @Override | ||
/* */ public boolean accept(File file) { | ||
/* */ try { | ||
/* 52 */ Path path = file.toPath(); | ||
/* 53 */ return visitFile(path, file | ||
/* 54 */ .exists() ? PathUtils.readBasicFileAttributes(path) : null) == FileVisitResult.CONTINUE; | ||
/* */ } catch (IOException e) { | ||
/* 56 */ return handle(e) == FileVisitResult.CONTINUE; | ||
/* */ } | ||
/* */ } | ||
/* */ | ||
/* */ @Override | ||
/* */ public boolean accept(File dir, String name) { | ||
/* */ try { | ||
/* 63 */ Path path = dir.toPath().resolve(name); | ||
/* 64 */ return accept(path, PathUtils.readBasicFileAttributes(path)) == FileVisitResult.CONTINUE; | ||
/* */ } catch (IOException e) { | ||
/* 66 */ return handle(e) == FileVisitResult.CONTINUE; | ||
/* */ } | ||
/* */ } | ||
/* */ | ||
/* */ @Override | ||
/* */ public FileVisitResult accept(Path path, BasicFileAttributes attributes) { | ||
/* */ try { | ||
/* 73 */ return Files.isDirectory(path) ? this.pathVisitor.postVisitDirectory(path, null) : visitFile(path, attributes); | ||
/* */ } catch (IOException e) { | ||
/* 75 */ return handle(e); | ||
/* */ } | ||
/* */ } | ||
/* */ | ||
/* */ @Override | ||
/* */ public FileVisitResult visitFile(Path path, BasicFileAttributes attributes) throws IOException { | ||
/* 81 */ return this.pathVisitor.visitFile(path, attributes); | ||
/* */ } | ||
/* */ } |