1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-28 09:24:14 +01:00

Moving a sketch to another folder should move all files

Fixes #6402
This commit is contained in:
Martino Facchin 2017-06-21 10:42:03 +02:00
parent 73f40ac32e
commit c4f5cafd33
2 changed files with 7 additions and 1 deletions

View File

@ -72,6 +72,8 @@ import java.util.ArrayList;
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.
*/
@ -1935,7 +1937,7 @@ public class Editor extends JFrame implements RunnerListener {
// 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;

View File

@ -58,6 +58,10 @@ public class FileUtils {
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);