1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-13 10:29:35 +01:00

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.
This commit is contained in:
jeroenoverman 2017-03-07 17:14:00 +01:00
parent 1f35bfca53
commit 7714a41c0c

View File

@ -351,13 +351,22 @@ public class Sketch {
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;
}
/**