diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 0125feb95..31643c94d 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -72,6 +72,8 @@ import java.util.ArrayList; import static processing.app.I18n.tr; import static processing.app.Theme.scale; +import processing.app.helpers.FileUtils; + /** * Main editor panel for the Processing Development Environment. */ @@ -1935,7 +1937,7 @@ public class Editor extends JFrame implements RunnerListener { // copy the sketch inside File properPdeFile = new File(properFolder, sketchFile.getName()); try { - Base.copyFile(sketchFile, properPdeFile); + FileUtils.copy(new File(sketchFile.getParent()), properFolder); } catch (IOException e) { Base.showWarning(tr("Error"), tr("Could not copy to a proper location."), e); return false; diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java index 5e30319dc..654a5d95a 100644 --- a/arduino-core/src/processing/app/helpers/FileUtils.java +++ b/arduino-core/src/processing/app/helpers/FileUtils.java @@ -58,6 +58,10 @@ public class FileUtils { public static void copy(File sourceFolder, File destFolder) throws IOException { for (File file : sourceFolder.listFiles()) { File destFile = new File(destFolder, file.getName()); + if ((destFolder.getPath().equals(file.getPath()))) { + // Avoid recursive copy of folders + continue; + } if (file.isDirectory() && !SOURCE_CONTROL_FOLDERS.contains(file.getName())) { if (!destFile.exists() && !destFile.mkdir()) { throw new IOException("Unable to create folder: " + destFile);