Commons IO
  1. Commons IO
  2. IO-34

[io] FileSystemUtils returns incorrect free space on Linux

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: Linux
      Platform: Other

      Description

      Re: Commons-IO class FileSystemUtils

      The method freeSpace(String path) returns free disk space in bytes on Windows,
      and returns free disk space in kilobytes (not bytes) on Linux (possibly Unix /
      Mac OS etc. also).

      The internal method freeSpaceUnix javadoc reads "Find free space on the *nix
      platform using the 'df' command." The value returned by df is read in to a
      variable called bytes and returned. Man pages for df on Linux (Fedora Core 4)
      read "Disk space is shown in 1K blocks by default". So method
      freeSpaceUnix is returning the number of kilobytes free space, not bytes.

      A simple fix could be to add line "bytes = bytes * 1024;" after bytes are read in.

      The javadocs for this class could be improved also. Comment "@return the amount
      of free drive space on the volume" could read "@return the amount of free drive
      space on the volume in bytes".

        Activity

        Hide
        Stephen Colebourne added a comment -

        FileSystemUtils.freeSpaceKb(drive)
        New method that unifies result to be in kilobytes

        Please reopen if you believe that the new method returns the wrong result (I can
        on test on Windows)

        Show
        Stephen Colebourne added a comment - FileSystemUtils.freeSpaceKb(drive) New method that unifies result to be in kilobytes Please reopen if you believe that the new method returns the wrong result (I can on test on Windows)
        Hide
        Stephen Colebourne added a comment -

        Reopening to change versions

        Show
        Stephen Colebourne added a comment - Reopening to change versions

          People

          • Assignee:
            Unassigned
            Reporter:
            Niall Gallagher
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development