Speaking of classic command-line utilities, one final thing we might want to do with a filesystem is ask how full it is. This is the domain of the command-line utility df -h or the POSIX library function statvfs. In C++17, we can do it with fs::space("path"), which returns (by value) a struct of type fs::space_info:
struct space_info {
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
};
Each of these fields is measured in bytes, and we should have available <= free <= capacity. The distinction between available and free has to do with user limits: On some filesystems, a portion of the free space might be reserved for the root user, and on others, there might be per-user-account disk quotas.