Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: base/sys_info_posix.cc

Issue 3141: Move GetFreeDiskSpace to SysInfo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_posix.cc
===================================================================
--- base/sys_info_posix.cc (revision 2357)
+++ base/sys_info_posix.cc (working copy)
@@ -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
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698