6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
Reviewed-by: chegar
diff --git a/test/java/nio/file/TestUtil.java b/test/java/nio/file/TestUtil.java
index 2436a45..972dc25 100644
--- a/test/java/nio/file/TestUtil.java
+++ b/test/java/nio/file/TestUtil.java
@@ -30,17 +30,20 @@
private TestUtil() {
}
- public static Path createTemporaryDirectory() throws IOException {
- Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
+ static Path createTemporaryDirectory(String where) throws IOException {
+ Path top = FileSystems.getDefault().getPath(where);
Random r = new Random();
-
Path dir;
do {
- dir = tmpdir.resolve("name" + r.nextInt());
+ dir = top.resolve("name" + r.nextInt());
} while (dir.exists());
return dir.createDirectory();
}
+ static Path createTemporaryDirectory() throws IOException {
+ return createTemporaryDirectory(System.getProperty("java.io.tmpdir"));
+ }
+
static void removeAll(Path dir) {
Files.walkFileTree(dir, new FileVisitor<Path>() {
@Override