diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-18 12:34:24 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-18 12:34:24 +0000 |
commit | 0e91dd2a1cec40c6fa0390c890e10dc75398de34 (patch) | |
tree | f4385248c0abb048ec718cb555b5287847bc4429 /base/sys_info_posix.cc | |
parent | fadf97f2f16f6b3ad2756cd07657c4f47172da92 (diff) | |
download | chromium_src-0e91dd2a1cec40c6fa0390c890e10dc75398de34.zip chromium_src-0e91dd2a1cec40c6fa0390c890e10dc75398de34.tar.gz chromium_src-0e91dd2a1cec40c6fa0390c890e10dc75398de34.tar.bz2 |
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
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 |