Skip to content

free disk space improvements#4

Open
xwang1498 wants to merge 3 commits into
bingmann:masterfrom
xwang1498:free-disk-size-windows
Open

free disk space improvements#4
xwang1498 wants to merge 3 commits into
bingmann:masterfrom
xwang1498:free-disk-size-windows

Conversation

@xwang1498

@xwang1498 xwang1498 commented Dec 21, 2023

Copy link
Copy Markdown

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