disk-filltest icon indicating copy to clipboard operation
disk-filltest copied to clipboard

free disk space improvements

Open xwang1498 opened this issue 2 years ago • 0 comments

a few improvements to free disk space calculation:

  1. On Windows, use GetDiskFreeSpaceEx.
  2. Use f_frsize instead of f_bsize, to get the correct block size on macOS (doesn't affect Windows or Linux).
  3. Use f_bfree & f_bavail to compute free blocks. Previous f_blocks was computing total blocks, rather than free blocks. Choose bfree or bavail based on whether we're privileged or not. This matters on Linux, where part of the filesystem is often reserved for root.

Tested on Windows (x86_64-w64-mingw32-gcc), Cygwin (uses statvfs api), macOS, Linux, but not on MSVC.

xwang1498 avatar Dec 21 '23 02:12 xwang1498