-
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.
Attempt at creating a file visitor that works with tree items
- Loading branch information
Showing
3 changed files
with
75 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main.java; | ||
|
||
import javafx.scene.control.TreeItem; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.FileVisitResult; | ||
import java.nio.file.Path; | ||
import java.nio.file.SimpleFileVisitor; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.io.File; | ||
|
||
/** | ||
* Created by kristopherguzman on 2/11/16. | ||
*/ | ||
public class IronFileVisitor extends SimpleFileVisitor<Path> { | ||
|
||
private TreeItem<String> currentDirectory; | ||
|
||
@Override | ||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { | ||
|
||
return FileVisitResult.CONTINUE; | ||
} | ||
/** | ||
* {@inheritDoc} | ||
* This method must be overridden so that walking the tree can continue. | ||
* */ | ||
@Override | ||
public FileVisitResult visitFileFailed(Path file, IOException e) throws IOException { | ||
System.err.printf("Visiting failed for %s\n", file); | ||
return FileVisitResult.SKIP_SUBTREE; | ||
} | ||
@Override | ||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { | ||
System.out.printf("About to visit directory %s\n", dir); | ||
|
||
currentDirectory = new TreeItem<String>(dir.getFileName().toString()); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException { | ||
System.out.printf("About to visit directory %s\n", dir); | ||
|
||
|
||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
} |