diff options
Diffstat (limited to 'base/sys_info_posix.cc')
-rw-r--r-- | base/sys_info_posix.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index a9a91cd..541a424 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -7,6 +7,7 @@ #include <errno.h> #include <string.h> +#include <sys/statvfs.h> #include <unistd.h> #if defined(OS_MACOSX) @@ -15,6 +16,7 @@ #endif #include "base/logging.h" +#include "base/string_util.h" namespace base { @@ -59,4 +61,13 @@ int64 SysInfo::AmountOfPhysicalMemory() { #endif } +// static +int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) { + struct statvfs stats; + if (statvfs(WideToUTF8(path).c_str(), &stats) != 0) { + return 0; + } + return static_cast<int64>(stats.f_bavail) * stats.f_frsize; +} + } // namespace base |