summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 00:41:56 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 00:41:56 +0000
commit13326bbed15f36965826368a0079742e7ba530ce (patch)
treee2a17b387979295ad867429afb2322861f850ece /base
parent5753f39acbb4e6dfba42634d2fbc203a0a9ccccf (diff)
downloadchromium_src-13326bbed15f36965826368a0079742e7ba530ce.zip
chromium_src-13326bbed15f36965826368a0079742e7ba530ce.tar.gz
chromium_src-13326bbed15f36965826368a0079742e7ba530ce.tar.bz2
Convert SysInfo::AmountOfFreeDiskSpace from wstring to FilePath.
BUG=24672 Review URL: http://codereview.chromium.org/276012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/sys_info.h4
-rw-r--r--base/sys_info_posix.cc4
-rw-r--r--base/sys_info_unittest.cc2
-rw-r--r--base/sys_info_win.cc5
4 files changed, 9 insertions, 6 deletions
diff --git a/base/sys_info.h b/base/sys_info.h
index 5469da54..7460fe0 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -9,6 +9,8 @@
#include <string>
+class FilePath;
+
namespace base {
class SysInfo {
@@ -26,7 +28,7 @@ class SysInfo {
// Return the available disk space in bytes on the volume containing |path|,
// or -1 on failure.
- static int64 AmountOfFreeDiskSpace(const std::wstring& path);
+ static int64 AmountOfFreeDiskSpace(const FilePath& path);
// Return true if the given environment variable is defined.
// TODO: find a better place for HasEnvVar.
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 74a10ac..41afff2 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -86,9 +86,9 @@ int64 SysInfo::AmountOfPhysicalMemory() {
}
// static
-int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
+int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
struct statvfs stats;
- if (statvfs(WideToUTF8(path).c_str(), &stats) != 0) {
+ if (statvfs(path.value().c_str(), &stats) != 0) {
return -1;
}
return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc
index 160abd6..31f314f 100644
--- a/base/sys_info_unittest.cc
+++ b/base/sys_info_unittest.cc
@@ -24,7 +24,7 @@ TEST_F(SysInfoTest, AmountOfFreeDiskSpace) {
// We aren't actually testing that it's correct, just that it's sane.
FilePath tmp_path;
ASSERT_TRUE(file_util::GetTempDir(&tmp_path));
- EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path.ToWStringHack()), 0)
+ EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0)
<< tmp_path.value();
}
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc
index 8e1a7ba..ebb95c7ba 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -6,6 +6,7 @@
#include <windows.h>
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
@@ -35,9 +36,9 @@ int64 SysInfo::AmountOfPhysicalMemory() {
}
// static
-int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
+int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
ULARGE_INTEGER available, total, free;
- if (!GetDiskFreeSpaceExW(path.c_str(), &available, &total, &free)) {
+ if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) {
return -1;
}
int64 rv = static_cast<int64>(available.QuadPart);