Skip to content

Commit 258d6d5

Browse files
facchinmcmaglie
authored andcommitted
Moving a sketch to another folder should move all files
Fixes #6402
1 parent b642b9a commit 258d6d5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/src/processing/app/Editor.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
import static processing.app.I18n.tr;
7373
import static processing.app.Theme.scale;
7474

75+
import processing.app.helpers.FileUtils;
76+
7577
/**
7678
* Main editor panel for the Processing Development Environment.
7779
*/
@@ -1935,7 +1937,7 @@ protected boolean handleOpenInternal(File sketchFile) {
19351937
// copy the sketch inside
19361938
File properPdeFile = new File(properFolder, sketchFile.getName());
19371939
try {
1938-
Base.copyFile(sketchFile, properPdeFile);
1940+
FileUtils.copy(new File(sketchFile.getParent()), properFolder);
19391941
} catch (IOException e) {
19401942
Base.showWarning(tr("Error"), tr("Could not copy to a proper location."), e);
19411943
return false;

arduino-core/src/processing/app/helpers/FileUtils.java

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public static void copyFile(File source, File dest) throws IOException {
5858
public static void copy(File sourceFolder, File destFolder) throws IOException {
5959
for (File file : sourceFolder.listFiles()) {
6060
File destFile = new File(destFolder, file.getName());
61+
if ((destFolder.getPath().equals(file.getPath()))) {
62+
// Avoid recursive copy of folders
63+
continue;
64+
}
6165
if (file.isDirectory() && !SOURCE_CONTROL_FOLDERS.contains(file.getName())) {
6266
if (!destFile.exists() && !destFile.mkdir()) {
6367
throw new IOException("Unable to create folder: " + destFile);

0 commit comments

Comments
 (0)