Move GetFreeDiskSpace to SysInfo.

Patch from Pawel Hajdan Jr.
Review URL: http://codereview.chromium.org/3141

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2359 0039d316-1c4b-4281-b951-d872f2087c98
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 @@
 #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