Skip to content

Commit 14b3f9b

Browse files
authored
Merge pull request #6041 from delftswa2017/bug/data-folder
Fix "save as" operation for the data folder of a sketch
2 parents 938df21 + 7714a41 commit 14b3f9b

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)