Index: platform.cc |
diff --git a/platform.cc b/platform.cc |
index 35d0cdd690f3bbbc17ac910097adeb44fe671f8e..071e06a3b30937828fa8ad9734ccde1da3884715 100644 |
--- a/platform.cc |
+++ b/platform.cc |
@@ -12,6 +12,7 @@ |
#include <signal.h> |
#include <sys/mount.h> |
#include <sys/stat.h> |
+#include <sys/statvfs.h> |
#include <sys/types.h> |
#include <base/file_util.h> |
@@ -366,6 +367,14 @@ bool Platform::GetUserId(const std::string& user, uid_t* user_id, |
return true; |
} |
+int64 Platform::AmountOfFreeDiskSpace(const string& path) { |
+ struct statvfs stats; |
+ if (statvfs(path.c_str(), &stats) != 0) { |
+ return -1; |
+ } |
+ return static_cast<int64>(stats.f_bavail) * stats.f_frsize; |
+} |
+ |
void Platform::ClearUserKeyring() { |
keyctl(KEYCTL_CLEAR, KEY_SPEC_USER_KEYRING); |
} |