James Moger
2011-07-20 330247866e931d5e5f93999db9947bc2fc1fc9ee
src/com/gitblit/utils/FileUtils.java
@@ -34,7 +34,7 @@
    * 
    * @param file
    * @param lineEnding
    * @return
    * @return the string content of the file
    */
   public static String readContent(File file, String lineEnding) {
      StringBuilder sb = new StringBuilder();
@@ -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;
   }
}