mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Moved removeDescendants() and removeDir() from Base to BaseNoGui.
This commit is contained in:
committed by
Cristian Maglie
parent
7c58be397b
commit
36fd0bf344
@ -2604,12 +2604,7 @@ public class Base {
|
|||||||
* Remove all files in a directory and the directory itself.
|
* Remove all files in a directory and the directory itself.
|
||||||
*/
|
*/
|
||||||
static public void removeDir(File dir) {
|
static public void removeDir(File dir) {
|
||||||
if (dir.exists()) {
|
BaseNoGui.removeDir(dir);
|
||||||
removeDescendants(dir);
|
|
||||||
if (!dir.delete()) {
|
|
||||||
System.err.println(I18n.format(_("Could not delete {0}"), dir));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2620,24 +2615,7 @@ public class Base {
|
|||||||
* (i.e. when cleaning temp files from lib/build)
|
* (i.e. when cleaning temp files from lib/build)
|
||||||
*/
|
*/
|
||||||
static public void removeDescendants(File dir) {
|
static public void removeDescendants(File dir) {
|
||||||
if (!dir.exists()) return;
|
BaseNoGui.removeDescendants(dir);
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,6 +391,45 @@ public class BaseNoGui {
|
|||||||
PreferencesData.init(absoluteFile(preferencesFile));
|
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.
|
* Spew the contents of a String object out to a file.
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,6 @@ import java.util.Map;
|
|||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import processing.app.Base;
|
|
||||||
import processing.app.BaseNoGui;
|
import processing.app.BaseNoGui;
|
||||||
import processing.app.I18n;
|
import processing.app.I18n;
|
||||||
import processing.app.PreferencesData;
|
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
|
// 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
|
// 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
|
// will ignore the fact that that dir is in the CLASSPATH in run.sh
|
||||||
Base.removeDescendants(tempBuildFolder);
|
BaseNoGui.removeDescendants(tempBuildFolder);
|
||||||
} else {
|
} else {
|
||||||
// delete only stale source files, from the previously
|
// delete only stale source files, from the previously
|
||||||
// compiled sketch. This allows multiple windows to be
|
// compiled sketch. This allows multiple windows to be
|
||||||
|
Reference in New Issue
Block a user