std::experimental::filesystem::space

Header: <experimental/filesystem>

Determines the information about the filesystem on which the pathname p is located, as if by POSIX statvfs.

# Declarations

space_info space( const path& p );
space_info space( const path& p, error_code& ec ) noexcept;

(filesystem TS)

# Parameters

# Return value

The filesystem information (a space_info object).

# Notes

space_info.available may be less than space_info.free.

# Example

#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
 
int main()
{
    fs::space_info devi = fs::space("/dev/null");
    fs::space_info tmpi = fs::space("/tmp");
 
    std::cout << "         Capacity         Free    Available\n"
              << "/dev:   " << devi.capacity << "   "
              << devi.free << "   " << devi.available << '\n'
              << "/tmp: " << tmpi.capacity << ' '
              << tmpi.free << ' ' << tmpi.available << '\n';
}

# See also