|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
24 | 24 | import java.nio.file.SimpleFileVisitor;
|
25 | 25 | import java.nio.file.StandardCopyOption;
|
26 | 26 | import java.nio.file.attribute.BasicFileAttributes;
|
| 27 | +import java.util.EnumSet; |
27 | 28 |
|
28 | 29 | import org.springframework.lang.Nullable;
|
29 | 30 |
|
| 31 | +import static java.nio.file.FileVisitOption.FOLLOW_LINKS; |
| 32 | + |
30 | 33 | /**
|
31 | 34 | * Utility methods for working with the file system.
|
32 | 35 | *
|
@@ -65,11 +68,11 @@ public static boolean deleteRecursively(@Nullable File root) {
|
65 | 68 | }
|
66 | 69 |
|
67 | 70 | /**
|
68 |
| - * Delete the supplied {@link File} - for directories, |
| 71 | + * Delete the supplied {@link File} — for directories, |
69 | 72 | * recursively delete any nested directories or files as well.
|
70 | 73 | * @param root the root {@code File} to delete
|
71 | 74 | * @return {@code true} if the {@code File} existed and was deleted,
|
72 |
| - * or {@code false} it it did not exist |
| 75 | + * or {@code false} if it did not exist |
73 | 76 | * @throws IOException in the case of I/O errors
|
74 | 77 | * @since 5.0
|
75 | 78 | */
|
@@ -123,7 +126,7 @@ public static void copyRecursively(Path src, Path dest) throws IOException {
|
123 | 126 | BasicFileAttributes srcAttr = Files.readAttributes(src, BasicFileAttributes.class);
|
124 | 127 |
|
125 | 128 | if (srcAttr.isDirectory()) {
|
126 |
| - Files.walkFileTree(src, new SimpleFileVisitor<Path>() { |
| 129 | + Files.walkFileTree(src, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() { |
127 | 130 | @Override
|
128 | 131 | public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
129 | 132 | Files.createDirectories(dest.resolve(src.relativize(dir)));
|
|
0 commit comments