Skip to content

Commit

Permalink
Fix copy data folder when performing save as operation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeroenoverman committed Mar 7, 2017
1 parent 1f35bfc commit 7714a41
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion arduino-core/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

/**
Expand Down

0 comments on commit 7714a41

Please sign in to comment.