MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / __space

Function __space

system/lib/libcxx/src/filesystem/operations.cpp:977–996  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975}
976
977space_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
998file_status __status(const path& p, error_code* ec) { return detail::posix_stat(p, ec); }
999

Callers 1

space_info spaceFunction · 0.85

Calls 4

get_last_errorFunction · 0.85
reportMethod · 0.80
statvfsFunction · 0.70
c_strMethod · 0.45

Tested by

no test coverage detected