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

Side by Side Diff: base/sys_info_posix.cc

Issue 2876045: base: Get rid of the deprecated SysInfo::GetEnvVar. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: " Created 10 years, 5 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 unified diff | Download patch
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/param.h> 9 #include <sys/param.h>
10 #include <sys/statvfs.h> 10 #include <sys/statvfs.h>
(...skipping 29 matching lines...) Expand all
40 // static 40 // static
41 int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { 41 int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
42 struct statvfs stats; 42 struct statvfs stats;
43 if (statvfs(path.value().c_str(), &stats) != 0) { 43 if (statvfs(path.value().c_str(), &stats) != 0) {
44 return -1; 44 return -1;
45 } 45 }
46 return static_cast<int64>(stats.f_bavail) * stats.f_frsize; 46 return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
47 } 47 }
48 48
49 // static 49 // static
50 std::wstring SysInfo::GetEnvVar(const wchar_t* var) {
51 std::string var_utf8 = WideToUTF8(std::wstring(var));
52 char* value = getenv(var_utf8.c_str());
53 if (!value) {
54 return std::wstring();
55 } else {
56 return UTF8ToWide(value);
57 }
58 }
59
60 // static
61 std::string SysInfo::OperatingSystemName() { 50 std::string SysInfo::OperatingSystemName() {
62 utsname info; 51 utsname info;
63 if (uname(&info) < 0) { 52 if (uname(&info) < 0) {
64 NOTREACHED(); 53 NOTREACHED();
65 return ""; 54 return "";
66 } 55 }
67 return std::string(info.sysname); 56 return std::string(info.sysname);
68 } 57 }
69 58
70 // static 59 // static
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return gdk_screen_get_n_monitors(screen); 99 return gdk_screen_get_n_monitors(screen);
111 } 100 }
112 #endif 101 #endif
113 102
114 // static 103 // static
115 size_t SysInfo::VMAllocationGranularity() { 104 size_t SysInfo::VMAllocationGranularity() {
116 return getpagesize(); 105 return getpagesize();
117 } 106 }
118 107
119 } // namespace base 108 } // namespace base
OLDNEW
« 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