return FileVisitResult.CONTINUE;
} else if (dir.getParent().getFileName().toString().equals(IDENTIFIER)) {
Path targetPath = toPath.resolve(dirName);
- if (!Files.exists(targetPath)) {
- Files.createDirectory(targetPath);
- }
+ Files.createDirectories(targetPath);
return FileVisitResult.CONTINUE;
} else if (dirName.toString().length() == 1 && Character.isDigit(dirName.toString().charAt(0))) {
int dirNameInt = Integer.parseInt(dirName.toString());
@Override
public FileVisitResult preVisitDirectory(Path dir,
BasicFileAttributes attrs) throws IOException {
- Path dirName = dir.getFileName();
- if (dirName.equals(fromPath)) {
+ if (dir.equals(fromPath)) {
Path targetPath = toPath.resolve(fromPath.relativize(dir));
- if (!Files.exists(targetPath)) {
- Files.createDirectory(targetPath);
- }
+ Files.createDirectories(targetPath);
return FileVisitResult.CONTINUE;
} else {
- int dirNameInt = Integer.parseInt(dirName.toString());
- if (latestFolder < dirNameInt && dirNameInt <= newestFolder) {
- Path targetPath = toPath.resolve(fromPath
- .relativize(dir));
- if (!Files.exists(targetPath)) {
- Files.createDirectory(targetPath);
+ try {
+ int dirNameInt = Integer.parseInt(dir.getFileName().toString());
+ if (latestFolder < dirNameInt && dirNameInt <= newestFolder) {
+ Path targetPath = toPath.resolve(fromPath.relativize(dir));
+ Files.createDirectories(targetPath);
+ return FileVisitResult.CONTINUE;
}
- return FileVisitResult.CONTINUE;
+ } catch (NumberFormatException e) {
}
return FileVisitResult.SKIP_SUBTREE;
}