Index: base/sys_info_posix.cc |
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc |
index 85ae039118986d211ea3964e38f271c4beb3a026..168e3aee5365a41ee3c9c9f27105655c0ee646fd 100644 |
--- a/base/sys_info_posix.cc |
+++ b/base/sys_info_posix.cc |
@@ -90,12 +90,25 @@ int64_t SysInfo::AmountOfVirtualMemory() { |
// static |
int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { |
- base::ThreadRestrictions::AssertIOAllowed(); |
+ int64_t available, unused; |
+ if (!GetDiskSpaceInfo(path, &available, &unused)) |
+ return -1; |
+ return available; |
+} |
+ |
+// static |
+bool SysInfo::GetDiskSpaceInfo(const FilePath& path, |
+ int64_t* available_bytes, |
+ int64_t* total_bytes) { |
+ ThreadRestrictions::AssertIOAllowed(); |
struct statvfs stats; |
if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0) |
- return -1; |
- return static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; |
+ return false; |
+ |
+ *available_bytes = static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; |
+ *total_bytes = static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; |
+ return true; |
} |
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) |