@Nullable private List<VirtualFile> copyVirtualFilesToDir(@NotNull VirtualFile targetDir) { List<VirtualFile> copiedFiles = Lists.newArrayList(); for (VirtualFile virtualFile : myAdapterSourceFiles) { try { //noinspection NullableProblems copiedFiles.add(VfsUtilCore.copyFile(null, virtualFile, targetDir)); } catch (IOException e) { Messages.showErrorDialog( "Extract operation failed!\nUnable to copy " + virtualFile.getPath() + " to " + targetDir.getPath(), "Adding " + getAssertFrameworkAdapterName()); return null; } } return copiedFiles; }
private VirtualFile createFileCopy(VirtualFile tempDir, final VirtualFile file) throws IOException { final String fileName = file.getName(); if (tempDir.findChild(fileName) != null) { int idx = 0; while (true) { //noinspection HardCodedStringLiteral final String dirName = "dir" + idx++; final VirtualFile dir = tempDir.findChild(dirName); if (dir == null) { tempDir = tempDir.createChildDirectory(this, dirName); break; } if (dir.findChild(fileName) == null) { tempDir = dir; break; } } } return VfsUtilCore.copyFile(this, file, tempDir); }