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

Side by Side Diff: base/linux_util.cc

Issue 774001: BSD port changes for base/ (OS_POSIX/GTK instead of OS_LINUX... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | base/process_posix.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/linux_util.h" 5 #include "base/linux_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <glib.h> 9 #include <glib.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (PathService::Get(base::DIR_TEMP, &rv)) 194 if (PathService::Get(base::DIR_TEMP, &rv))
195 return rv; 195 return rv;
196 196
197 // Last resort. 197 // Last resort.
198 return FilePath("/tmp"); 198 return FilePath("/tmp");
199 } 199 }
200 200
201 std::string GetLinuxDistro() { 201 std::string GetLinuxDistro() {
202 #if defined(OS_CHROMEOS) 202 #if defined(OS_CHROMEOS)
203 return linux_distro; 203 return linux_distro;
204 #else // if defined(OS_LINUX) 204 #elif defined(OS_LINUX)
205 LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get(); 205 LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get();
206 LinuxDistroState state = distro_state_singleton->State(); 206 LinuxDistroState state = distro_state_singleton->State();
207 if (STATE_DID_NOT_CHECK == state) { 207 if (STATE_DID_NOT_CHECK == state) {
208 // We do this check only once per process. If it fails, there's 208 // We do this check only once per process. If it fails, there's
209 // little reason to believe it will work if we attempt to run 209 // little reason to believe it will work if we attempt to run
210 // lsb_release again. 210 // lsb_release again.
211 std::vector<std::string> argv; 211 std::vector<std::string> argv;
212 argv.push_back("lsb_release"); 212 argv.push_back("lsb_release");
213 argv.push_back("-d"); 213 argv.push_back("-d");
214 std::string output; 214 std::string output;
215 base::GetAppOutput(CommandLine(argv), &output); 215 base::GetAppOutput(CommandLine(argv), &output);
216 if (output.length() > 0) { 216 if (output.length() > 0) {
217 // lsb_release -d should return: Description:<tab>Distro Info 217 // lsb_release -d should return: Description:<tab>Distro Info
218 static const std::string field = "Description:\t"; 218 static const std::string field = "Description:\t";
219 if (output.compare(0, field.length(), field) == 0) { 219 if (output.compare(0, field.length(), field) == 0) {
220 linux_distro = output.substr(field.length()); 220 linux_distro = output.substr(field.length());
221 TrimWhitespaceASCII(linux_distro, TRIM_ALL, &linux_distro); 221 TrimWhitespaceASCII(linux_distro, TRIM_ALL, &linux_distro);
222 } 222 }
223 } 223 }
224 distro_state_singleton->CheckFinished(); 224 distro_state_singleton->CheckFinished();
225 return linux_distro; 225 return linux_distro;
226 } else if (STATE_CHECK_STARTED == state) { 226 } else if (STATE_CHECK_STARTED == state) {
227 // If the distro check above is in progress in some other thread, we're 227 // If the distro check above is in progress in some other thread, we're
228 // not going to wait for the results. 228 // not going to wait for the results.
229 return "Unknown"; 229 return "Unknown";
230 } else { 230 } else {
231 // In STATE_CHECK_FINISHED, no more writing to |linux_distro|. 231 // In STATE_CHECK_FINISHED, no more writing to |linux_distro|.
232 return linux_distro; 232 return linux_distro;
233 } 233 }
234 #else
235 NOTIMPLEMENTED();
234 #endif 236 #endif
235 } 237 }
236 238
237 FilePath GetXDGDirectory(EnvironmentVariableGetter* env, 239 FilePath GetXDGDirectory(EnvironmentVariableGetter* env,
238 const char* env_name, const char* fallback_dir) { 240 const char* env_name, const char* fallback_dir) {
239 std::string env_value; 241 std::string env_value;
240 if (env->Getenv(env_name, &env_value) && !env_value.empty()) 242 if (env->Getenv(env_name, &env_value) && !env_value.empty())
241 return FilePath(env_value); 243 return FilePath(env_value);
242 return GetHomeDir(env).Append(fallback_dir); 244 return GetHomeDir(env).Append(fallback_dir);
243 } 245 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 374 }
373 } 375 }
374 376
375 closedir(fd); 377 closedir(fd);
376 } 378 }
377 379
378 return already_found; 380 return already_found;
379 } 381 }
380 382
381 } // namespace base 383 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | base/process_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698