diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 41fe9ea8f..5760b3748 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2604,12 +2604,7 @@ public class Base { * Remove all files in a directory and the directory itself. */ static public void removeDir(File dir) { - if (dir.exists()) { - removeDescendants(dir); - if (!dir.delete()) { - System.err.println(I18n.format(_("Could not delete {0}"), dir)); - } - } + BaseNoGui.removeDir(dir); } @@ -2620,24 +2615,7 @@ public class Base { * (i.e. when cleaning temp files from lib/build) */ static public void removeDescendants(File dir) { - if (!dir.exists()) return; - - String files[] = dir.list(); - for (int i = 0; i < files.length; i++) { - if (files[i].equals(".") || files[i].equals("..")) continue; - File dead = new File(dir, files[i]); - if (!dead.isDirectory()) { - if (!Preferences.getBoolean("compiler.save_build_files")) { - if (!dead.delete()) { - // temporarily disabled - System.err.println(I18n.format(_("Could not delete {0}"), dead)); - } - } - } else { - removeDir(dead); - //dead.delete(); - } - } + BaseNoGui.removeDescendants(dir); } diff --git a/app/src/processing/app/BaseNoGui.java b/app/src/processing/app/BaseNoGui.java index 81413d740..9e420503b 100644 --- a/app/src/processing/app/BaseNoGui.java +++ b/app/src/processing/app/BaseNoGui.java @@ -391,6 +391,45 @@ public class BaseNoGui { PreferencesData.init(absoluteFile(preferencesFile)); } + /** + * Recursively remove all files within a directory, + * used with removeDir(), or when the contents of a dir + * should be removed, but not the directory itself. + * (i.e. when cleaning temp files from lib/build) + */ + static public void removeDescendants(File dir) { + if (!dir.exists()) return; + + String files[] = dir.list(); + for (int i = 0; i < files.length; i++) { + if (files[i].equals(".") || files[i].equals("..")) continue; + File dead = new File(dir, files[i]); + if (!dead.isDirectory()) { + if (!Preferences.getBoolean("compiler.save_build_files")) { + if (!dead.delete()) { + // temporarily disabled + System.err.println(I18n.format(_("Could not delete {0}"), dead)); + } + } + } else { + removeDir(dead); + //dead.delete(); + } + } + } + + /** + * Remove all files in a directory and the directory itself. + */ + static public void removeDir(File dir) { + if (dir.exists()) { + removeDescendants(dir); + if (!dir.delete()) { + System.err.println(I18n.format(_("Could not delete {0}"), dir)); + } + } + } + /** * Spew the contents of a String object out to a file. */ diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index b606bb39c..d11cf9c87 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import processing.app.Base; import processing.app.BaseNoGui; import processing.app.I18n; import processing.app.PreferencesData; @@ -201,7 +200,7 @@ public class Compiler implements MessageConsumer { // the next time we start up, internal runs using Runner won't // work because the build dir won't exist at startup, so the classloader // will ignore the fact that that dir is in the CLASSPATH in run.sh - Base.removeDescendants(tempBuildFolder); + BaseNoGui.removeDescendants(tempBuildFolder); } else { // delete only stale source files, from the previously // compiled sketch. This allows multiple windows to be