Skip to content

Commit 7714a41

Browse files
committed
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.
1 parent 1f35bfc commit 7714a41

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arduino-core/src/processing/app/Sketch.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,22 @@ public void saveAs(File newFolder) throws IOException {
351351
file.saveAs(new File(newFolder, file.getFileName()));
352352
}
353353

354-
folder = newFolder;
355354

356355
// Copy the data folder (this may take a while.. add progress bar?)
357356
if (getDataFolder().exists()) {
358357
File newDataFolder = new File(newFolder, "data");
358+
// Check if data folder exits, if not try to create the data folder
359+
if (!newDataFolder.exists() && !newDataFolder.mkdirs()) {
360+
String msg = I18n.format(tr("Could not create directory \"{0}\""), newFolder.getAbsolutePath());
361+
throw new IOException(msg);
362+
}
363+
// Copy the data files into the new folder
359364
FileUtils.copy(getDataFolder(), newDataFolder);
360365
}
366+
367+
// Change folder to the new folder
368+
folder = newFolder;
369+
361370
}
362371

363372
/**

0 commit comments

Comments
 (0)