Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-34

[io] FileSystemUtils returns incorrect free space on Linux

    Details

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

      Operating System: Linux
      Platform: Other

    • Bugzilla Id:
      38574

      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".

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              niall@switchfire.com Niall Gallagher
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: