From 072bbe1b223c6f6c7a80ee86e00a41e15913b4ee Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 20 Jul 2011 15:50:54 -0400
Subject: [PATCH] Updated to Jetty 7.4.4
---
src/com/gitblit/utils/FileUtils.java | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/src/com/gitblit/utils/FileUtils.java b/src/com/gitblit/utils/FileUtils.java
index 468b2a8..ce8cdf9 100644
--- a/src/com/gitblit/utils/FileUtils.java
+++ b/src/com/gitblit/utils/FileUtils.java
@@ -56,4 +56,28 @@
}
return sb.toString();
}
+
+ /**
+ * Recursively traverses a folder and its subfolders to calculate the total
+ * size in bytes.
+ *
+ * @param directory
+ * @return folder size in bytes
+ */
+ public static long folderSize(File directory) {
+ if (directory == null || !directory.exists()) {
+ return -1;
+ }
+ if (directory.isFile()) {
+ return directory.length();
+ }
+ long length = 0;
+ for (File file : directory.listFiles()) {
+ if (file.isFile())
+ length += file.length();
+ else
+ length += folderSize(file);
+ }
+ return length;
+ }
}
--
Gitblit v1.9.1