mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 14:19:19 +01:00
Merge branch 'master' of github.com:processing/processing
This commit is contained in:
@@ -301,42 +301,40 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Remove all files in a directory and the directory itself.
|
||||
* Prints error messages with failed filenames.
|
||||
*/
|
||||
static public void removeDir(File dir) {
|
||||
if (dir.exists()) {
|
||||
removeDescendants(dir);
|
||||
if (!dir.delete()) {
|
||||
System.err.println("Could not delete " + dir);
|
||||
}
|
||||
}
|
||||
static public boolean removeDir(File dir) {
|
||||
return removeDir(dir, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* Remove all files in a directory and the directory itself.
|
||||
* Optinally prints error messages with failed filenames.
|
||||
*/
|
||||
static public void removeDescendants(File dir) {
|
||||
if (!dir.exists()) return;
|
||||
static public boolean removeDir(File dir, boolean printErrorMessages) {
|
||||
if (!dir.exists()) return true;
|
||||
|
||||
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("Could not delete " + dead);
|
||||
boolean result = true;
|
||||
File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
for (File child : files) {
|
||||
if (child.isFile()) {
|
||||
boolean deleted = child.delete();
|
||||
if (!deleted && printErrorMessages) {
|
||||
System.err.println("Could not delete " + child.getAbsolutePath());
|
||||
}
|
||||
result &= deleted;
|
||||
} else if (child.isDirectory()) {
|
||||
result &= removeDir(child, printErrorMessages);
|
||||
}
|
||||
} else {
|
||||
removeDir(dead);
|
||||
//dead.delete();
|
||||
}
|
||||
}
|
||||
boolean deleted = dir.delete();
|
||||
if (!deleted && printErrorMessages) {
|
||||
System.err.println("Could not delete " + dir.getAbsolutePath());
|
||||
}
|
||||
result &= deleted;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ public class AvailableContribution extends Contribution {
|
||||
}
|
||||
|
||||
// 4. Okay, now actually delete that temp folder
|
||||
Util.removeDir(newContribFolder);
|
||||
Util.removeDir(newContribFolder, false);
|
||||
|
||||
} else {
|
||||
if (status != null) {
|
||||
@@ -207,7 +207,7 @@ public class AvailableContribution extends Contribution {
|
||||
|
||||
// Remove any remaining boogers
|
||||
if (tempFolder.exists()) {
|
||||
Util.removeDir(tempFolder);
|
||||
Util.removeDir(tempFolder, false);
|
||||
}
|
||||
return installedContrib;
|
||||
}
|
||||
|
||||
@@ -449,8 +449,7 @@ public abstract class LocalContribution extends Contribution {
|
||||
if (doBackup) {
|
||||
success = backup(true, status);
|
||||
} else {
|
||||
Util.removeDir(getFolder());
|
||||
success = !getFolder().exists();
|
||||
success = Util.removeDir(getFolder(), false);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
||||
Reference in New Issue
Block a user