Skip to content

Commit

Permalink
Moving a sketch to another folder should move all files
Browse files Browse the repository at this point in the history
Fixes #6402
  • Loading branch information
facchinm committed Nov 13, 2017
1 parent 26265fc commit 3fca3ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/processing/app/Editor.java
Expand Up @@ -72,6 +72,8 @@
import static processing.app.I18n.tr;
import static processing.app.Theme.scale;

import processing.app.helpers.FileUtils;

/**
* Main editor panel for the Processing Development Environment.
*/
Expand Down Expand Up @@ -1935,7 +1937,7 @@ protected boolean handleOpenInternal(File sketchFile) {
// copy the sketch inside
File properPdeFile = new File(properFolder, sketchFile.getName());
try {
Base.copyFile(sketchFile, properPdeFile);
FileUtils.copy(new File(sketchFile.getParent()), properFolder);
} catch (IOException e) {
Base.showWarning(tr("Error"), tr("Could not copy to a proper location."), e);
return false;
Expand Down
4 changes: 4 additions & 0 deletions arduino-core/src/processing/app/helpers/FileUtils.java
Expand Up @@ -58,6 +58,10 @@ public static void copyFile(File source, File dest) throws IOException {
public static void copy(File sourceFolder, File destFolder) throws IOException {
for (File file : sourceFolder.listFiles()) {
File destFile = new File(destFolder, file.getName());
if ((destFolder.getPath().equals(file.getPath()))) {
// Avoid recursive copy of folders
continue;
}
if (file.isDirectory() && !SOURCE_CONTROL_FOLDERS.contains(file.getName())) {
if (!destFile.exists() && !destFile.mkdir()) {
throw new IOException("Unable to create folder: " + destFile);
Expand Down

0 comments on commit 3fca3ca

Please sign in to comment.