Commons IO
  1. Commons IO
  2. IO-326

Add new FileUtils.sizeOf[Directory] APIs to return BigInteger

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: Utilities
    • Labels:
      None

      Description

      FileUtils.sizeOfDirectory will return a negative number when the size count goes past Long.MAX_VALUE.

      Counting with a BigInteger will solve this issue. Options:

      • Change the signature of FileUtils.sizeOfDirectory() to return a BigInteger. This will obviously break BC.
      • Create a new API to return a BigInteger. What would this new API be called?
        • sizeOfDirectoryAsBigInteger
        • bigIntegerSizeOfDirectory
        • largeSizeOfDirectory
        • ...?
      1. IO-326.patch
        2 kB
        Bruno P. Kinoshita

        Activity

        Gary Gregory created issue -
        Gary Gregory made changes -
        Field Original Value New Value
        Summary Add or change FileUtils.sizeOfDirectory API that does not overflow Add or change FileUtils.sizeOfDirectory API such that it does not overflow
        Gary Gregory made changes -
        Summary Add or change FileUtils.sizeOfDirectory API such that it does not overflow Add new FileUtils.sizeOf[Directory] APIs to return BigInteger
        Gary Gregory committed 1326785 (2 files)
        Reviews: none

        First cut at [IO-326] Add new FileUtils.sizeOf[Directory] APIs to return BigInteger.

        Gary Gregory committed 1326787 (1 file)
        Reviews: none

        First cut at [IO-326] Add new FileUtils.sizeOf[Directory] APIs to return BigInteger.

        Hide
        Gary Gregory added a comment -

        Committed first cut as sizeOf[Directory]AsBigInteger

        Show
        Gary Gregory added a comment - Committed first cut as sizeOf [Directory] AsBigInteger
        Gary Gregory made changes -
        Fix Version/s 2.4 [ 12320769 ]
        Hide
        Jochen Wiedmann added a comment -

        Question: I believe to recall that we have discussed dropping BC for the next version anyways?

        If so: Do we really neeed to have sizeOf(dir) and sizeof(dir)AsBigInteger? I'd be in favour of
        having the latter only, with a long result.

        Show
        Jochen Wiedmann added a comment - Question: I believe to recall that we have discussed dropping BC for the next version anyways? If so: Do we really neeed to have sizeOf(dir) and sizeof(dir)AsBigInteger? I'd be in favour of having the latter only, with a long result.
        Hide
        Gary Gregory added a comment -

        If we break BC, then we can just change the return type of the current methods.
        Separately, we can add a org.apache.commons.io.FileUtils.byteCountToDisplaySize(BigInteger) and make the long version call the BigInteger version.

        Show
        Gary Gregory added a comment - If we break BC, then we can just change the return type of the current methods. Separately, we can add a org.apache.commons.io.FileUtils.byteCountToDisplaySize(BigInteger) and make the long version call the BigInteger version.
        Hide
        Gary Gregory added a comment -

        See also IO-327

        Show
        Gary Gregory added a comment - See also IO-327
        Hide
        Gary Gregory added a comment -

        Committed back in April.

        Show
        Gary Gregory added a comment - Committed back in April.
        Gary Gregory made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Bruno P. Kinoshita added a comment -

        Fixing unused return value of BigInteger.add()

        Show
        Bruno P. Kinoshita added a comment - Fixing unused return value of BigInteger.add()
        Bruno P. Kinoshita made changes -
        Attachment IO-326.patch [ 12531863 ]
        Gary Gregory committed 1349488 (3 files)
        Reviews: none

        [IO-326] Add new FileUtils.sizeOf[Directory] APIs to return BigInteger. Thanks to Bruno P. Kinoshita for the fix and test case.

        Gary Gregory committed 1349491 (1 file)
        Reviews: none

        [IO-326] Add new FileUtils.sizeOf[Directory] APIs to return BigInteger. Thanks to Bruno P. Kinoshita for the fix and test case.

          People

          • Assignee:
            Unassigned
            Reporter:
            Gary Gregory
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development