From ccec28ea45f880a2fe41b422efe66818b02e4532 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Dec 2015 17:01:10 +0100 Subject: [PATCH] Move sketch deletion from SketchController into Sketch This isn't much code, but it makes deletion more consistent with renaming and saving with the SketchController handling the UI part and Sketch actually doing the delete. --- app/src/processing/app/SketchController.java | 14 +------------- arduino-core/src/processing/app/Sketch.java | 7 +++++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/src/processing/app/SketchController.java b/app/src/processing/app/SketchController.java index 55321a795..0a0ba6f45 100644 --- a/app/src/processing/app/SketchController.java +++ b/app/src/processing/app/SketchController.java @@ -249,20 +249,8 @@ public class SketchController { options[0]); if (result == JOptionPane.YES_OPTION) { if (current.isPrimary()) { - // need to unset all the modified flags, otherwise tries - // to do a save on the handleNew() - - // delete the entire sketch - FileUtils.recursiveDelete(sketch.getFolder()); - - // get the changes into the sketchbook menu - //sketchbook.rebuildMenus(); - - // make a new sketch, and i think this will rebuild the sketch menu - //editor.handleNewUnchecked(); - //editor.handleClose2(); + sketch.delete(); editor.base.handleClose(editor); - } else { // delete the file if (!current.deleteFile(BaseNoGui.getBuildFolder(sketch).toPath())) { diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java index ee6dee70e..7c24c5e46 100644 --- a/arduino-core/src/processing/app/Sketch.java +++ b/arduino-core/src/processing/app/Sketch.java @@ -332,4 +332,11 @@ public class Sketch { FileUtils.copy(getDataFolder(), newDataFolder); } } + + /** + * Deletes this entire sketch from disk. + */ + void delete() { + FileUtils.recursiveDelete(folder); + } }