From 05f9b688e319fcb092be0e06f7b72d39dd3113b3 Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Mon, 29 Sep 2008 22:18:01 +0000 Subject: Refactoring for portability: - Move chrome/common/env_util to base/sys_info - Move chrome/common/rand_util to base/rand_util (new), simplify its public interface, and fix its implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Paweł Hajdan, Jr. http://codereview.chromium.org/4079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2697 0039d316-1c4b-4281-b951-d872f2087c98 --- base/sys_info_posix.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'base/sys_info_posix.cc') diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index 28c8bd6..b39457d 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #if defined(OS_MACOSX) @@ -70,4 +71,62 @@ int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) { return static_cast(stats.f_bavail) * stats.f_frsize; } +// static +bool SysInfo::HasEnvVar(const wchar_t* var) { + std::string var_utf8 = WideToUTF8(std::wstring(var)); + return getenv(var_utf8.c_str()) != NULL; +} + +// static +std::wstring SysInfo::GetEnvVar(const wchar_t* var) { + std::string var_utf8 = WideToUTF8(std::wstring(var)); + char* value = getenv(var_utf8.c_str()); + if (!value) { + return L""; + } else { + return UTF8ToWide(value); + } +} + +// static +std::string SysInfo::OperatingSystemName() { + utsname info; + if (uname(&info) < 0) { + NOTREACHED(); + return ""; + } + return std::string(info.sysname); +} + +// static +std::string SysInfo::OperatingSystemVersion() { + utsname info; + if (uname(&info) < 0) { + NOTREACHED(); + return ""; + } + return std::string(info.release); +} + +// static +std::string SysInfo::CPUArchitecture() { + utsname info; + if (uname(&info) < 0) { + NOTREACHED(); + return ""; + } + return std::string(info.machine); +} + +// static +void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) { + NOTIMPLEMENTED(); +} + +// static +int SysInfo::DisplayCount() { + NOTIMPLEMENTED(); + return 1; +} + } // namespace base -- cgit v1.1