From 7714a41c0c97f7c22ef377ef12c0976944b45fc6 Mon Sep 17 00:00:00 2001 From: jeroenoverman Date: Tue, 7 Mar 2017 17:14:00 +0100 Subject: [PATCH] Fix copy data folder when performing save as operation Changed the location where the variable `folder` gets updated. The function `getDataFolder()` uses this variable to return the data folder. It was looking for the data folder of the original sketch in the folder of the new created sketch. Furthermore the data folder will now be created if it does not exist yet in the new sketch before copying the files of the original sketch. --- arduino-core/src/processing/app/Sketch.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java index fa6a38bf041..6c417403ec9 100644 --- a/arduino-core/src/processing/app/Sketch.java +++ b/arduino-core/src/processing/app/Sketch.java @@ -351,13 +351,22 @@ public void saveAs(File newFolder) throws IOException { file.saveAs(new File(newFolder, file.getFileName())); } - folder = newFolder; // Copy the data folder (this may take a while.. add progress bar?) if (getDataFolder().exists()) { File newDataFolder = new File(newFolder, "data"); + // Check if data folder exits, if not try to create the data folder + if (!newDataFolder.exists() && !newDataFolder.mkdirs()) { + String msg = I18n.format(tr("Could not create directory \"{0}\""), newFolder.getAbsolutePath()); + throw new IOException(msg); + } + // Copy the data files into the new folder FileUtils.copy(getDataFolder(), newDataFolder); } + + // Change folder to the new folder + folder = newFolder; + } /**