summaryrefslogtreecommitdiffstats
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/gitblit/utils/FileUtils.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/utils/FileUtils.java b/src/main/java/com/gitblit/utils/FileUtils.java
index fb3e09ce..f3a25987 100644
--- a/src/main/java/com/gitblit/utils/FileUtils.java
+++ b/src/main/java/com/gitblit/utils/FileUtils.java
@@ -216,6 +216,30 @@ public class FileUtils {
}
/**
+ * Delete a file or recursively delete a folder.
+ *
+ * @param fileOrFolder
+ * @return true, if successful
+ */
+ public static boolean delete(File fileOrFolder) {
+ boolean success = false;
+ if (fileOrFolder.isDirectory()) {
+ File [] files = fileOrFolder.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ if (file.isDirectory()) {
+ success |= delete(file);
+ } else {
+ success |= file.delete();
+ }
+ }
+ }
+ }
+ success |= fileOrFolder.delete();
+ return success;
+ }
+
+ /**
* Copies a file or folder (recursively) to a destination folder.
*
* @param destinationFolder