Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free disk space improvements #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

xwang1498
Copy link

@xwang1498 xwang1498 commented Dec 21, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant