| 975 | } |
| 976 | |
| 977 | space_info __space(const path& p, error_code* ec) { |
| 978 | ErrorHandler<void> err("space", ec, &p); |
| 979 | space_info si; |
| 980 | detail::StatVFS m_svfs = {}; |
| 981 | if (detail::statvfs(p.c_str(), &m_svfs) == -1) { |
| 982 | err.report(detail::get_last_error()); |
| 983 | si.capacity = si.free = si.available = static_cast<uintmax_t>(-1); |
| 984 | return si; |
| 985 | } |
| 986 | // Multiply with overflow checking. |
| 987 | auto do_mult = [&](uintmax_t& out, uintmax_t other) { |
| 988 | out = other * m_svfs.f_frsize; |
| 989 | if (other == 0 || out / other != m_svfs.f_frsize) |
| 990 | out = static_cast<uintmax_t>(-1); |
| 991 | }; |
| 992 | do_mult(si.capacity, m_svfs.f_blocks); |
| 993 | do_mult(si.free, m_svfs.f_bfree); |
| 994 | do_mult(si.available, m_svfs.f_bavail); |
| 995 | return si; |
| 996 | } |
| 997 | |
| 998 | file_status __status(const path& p, error_code* ec) { return detail::posix_stat(p, ec); } |
| 999 |
no test coverage detected