mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Comeback of deleteDir
This commit is contained in:
@@ -301,8 +301,17 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Remove all files in a directory and the directory itself.
|
||||
* Prints error messages with failed filenames.
|
||||
*/
|
||||
static public boolean removeDir(File dir) {
|
||||
return removeDir(dir, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all files in a directory and the directory itself.
|
||||
* Optinally prints error messages with failed filenames.
|
||||
*/
|
||||
static public boolean removeDir(File dir, boolean printErrorMessages) {
|
||||
if (!dir.exists()) return true;
|
||||
|
||||
boolean result = true;
|
||||
@@ -310,13 +319,21 @@ public class Util {
|
||||
if (files != null) {
|
||||
for (File child : files) {
|
||||
if (child.isFile()) {
|
||||
result &= child.delete();
|
||||
boolean deleted = child.delete();
|
||||
if (!deleted && printErrorMessages) {
|
||||
System.err.println("Could not delete " + child.getAbsolutePath());
|
||||
}
|
||||
result &= deleted;
|
||||
} else if (child.isDirectory()) {
|
||||
result &= removeDir(child);
|
||||
result &= removeDir(child, printErrorMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
result &= dir.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