Author: ggregory Date: Mon Apr 16 19:34:53 2012 New Revision: 1326766 URL: http://svn.apache.org/viewvc?rev=1326766&view=rev Log: IO-319 document behavior with size > long and stop counting when long is < 0.
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java?rev=1326766&r1=1326765&r2=1326766&view=diff ============================================================================== --- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java (original) +++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java Mon Apr 16 19:34:53 2012 @@ -2353,10 +2353,13 @@ public class FileUtils { /** * Counts the size of a directory recursively (sum of the length of all files). - * - * @param directory directory to inspect, must not be {@code null} - * @return size of directory in bytes, 0 if directory is security restricted - * @throws NullPointerException if the directory is {@code null} + * + * @param directory + * directory to inspect, must not be {@code null} + * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total + * is greater than {@link Long#MAX_VALUE}. + * @throws NullPointerException + * if the directory is {@code null} */ public static long sizeOfDirectory(File directory) { if (!directory.exists()) { @@ -2377,6 +2380,9 @@ public class FileUtils { try { if (!isSymlink(file)) { size += sizeOf(file); + if (size < 0) { + break; + } } } catch (IOException ioe) { // Ignore exceptions caught when asking if a File is a symlink.