std::filesystem::space_info
From cppreference.com
< cpp | filesystem
Defined in header <filesystem>
|
||
struct space_info { std::uintmax_t capacity; |
(since C++17) | |
Represents the filesystem information as determined by space.
Member objects
capacity |
total size of the filesystem, in bytes (public member object) |
free |
free space on the filesystem, in bytes (public member object) |
available |
free space available to a non-privileged process (may be equal or less than free ) (public member object) |
Non-member functions
operator== (C++20) |
compares two space_info s (function) |
operator==(std::filesystem::space_info)
friend bool operator==( const space_info&, const space_info& ) = default; |
(since C++20) | |
Checks if capacity
, free
and available
of both arguments are equal respectively.
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::filesystem::space_info
is an associated class of the arguments.
Example
Run this code
#include <iostream> #include <filesystem> namespace fs = std::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'; }
Possible output:
. Capacity Free Available /dev: 4175114240 4175110144 4175110144 /tmp: 420651237376 411962273792 390570749952
See also
(C++17) |
determines available free space on the file system (function) |