diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-29 22:18:01 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-29 22:18:01 +0000 |
commit | 05f9b688e319fcb092be0e06f7b72d39dd3113b3 (patch) | |
tree | 6d24be7f9b788bbebbff6b2349e51dec49034ce6 /base/sys_info_posix.cc | |
parent | 86ec30d6710923cf1c193eb88b1e6251f831e0ef (diff) | |
download | chromium_src-05f9b688e319fcb092be0e06f7b72d39dd3113b3.zip chromium_src-05f9b688e319fcb092be0e06f7b72d39dd3113b3.tar.gz chromium_src-05f9b688e319fcb092be0e06f7b72d39dd3113b3.tar.bz2 |
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
Patch by Paweł Hajdan, Jr. <phajdan.jr@gmail.com>
http://codereview.chromium.org/4079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info_posix.cc')
-rw-r--r-- | base/sys_info_posix.cc | 59 |
1 files changed, 59 insertions, 0 deletions
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 <errno.h> #include <string.h> #include <sys/statvfs.h> +#include <sys/utsname.h> #include <unistd.h> #if defined(OS_MACOSX) @@ -70,4 +71,62 @@ int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) { return static_cast<int64>(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 |