| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Defines base::PathProviderPosix, default path provider on POSIX OSes that | 5 // Defines base::PathProviderPosix, default path provider on POSIX OSes that |
| 6 // don't have their own base_paths_OS.cc implementation (i.e. all but Mac and | 6 // don't have their own base_paths_OS.cc implementation (i.e. all but Mac and |
| 7 // Android). | 7 // Android). |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #if defined(OS_FREEBSD) | 27 #if defined(OS_FREEBSD) |
| 28 #include <sys/param.h> | 28 #include <sys/param.h> |
| 29 #include <sys/sysctl.h> | 29 #include <sys/sysctl.h> |
| 30 #elif defined(OS_SOLARIS) || defined(OS_AIX) | 30 #elif defined(OS_SOLARIS) || defined(OS_AIX) |
| 31 #include <stdlib.h> | 31 #include <stdlib.h> |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace base { | 34 namespace base { |
| 35 | 35 |
| 36 bool PathProviderPosix(int key, FilePath* result) { | 36 bool PathProviderPosix(int key, FilePath* result) { |
| 37 FilePath path; | |
| 38 switch (key) { | 37 switch (key) { |
| 39 case FILE_EXE: | 38 case FILE_EXE: |
| 40 case FILE_MODULE: { // TODO(evanm): is this correct? | 39 case FILE_MODULE: { // TODO(evanm): is this correct? |
| 41 #if defined(OS_LINUX) | 40 #if defined(OS_LINUX) |
| 42 FilePath bin_dir; | 41 FilePath bin_dir; |
| 43 if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { | 42 if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { |
| 44 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; | 43 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; |
| 45 return false; | 44 return false; |
| 46 } | 45 } |
| 47 *result = bin_dir; | 46 *result = bin_dir; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 else | 74 else |
| 76 *result = FilePath("/usr/local/chrome/chrome"); | 75 *result = FilePath("/usr/local/chrome/chrome"); |
| 77 return true; | 76 return true; |
| 78 #endif | 77 #endif |
| 79 } | 78 } |
| 80 case DIR_SOURCE_ROOT: { | 79 case DIR_SOURCE_ROOT: { |
| 81 // Allow passing this in the environment, for more flexibility in build | 80 // Allow passing this in the environment, for more flexibility in build |
| 82 // tree configurations (sub-project builds, gyp --output_dir, etc.) | 81 // tree configurations (sub-project builds, gyp --output_dir, etc.) |
| 83 std::unique_ptr<Environment> env(Environment::Create()); | 82 std::unique_ptr<Environment> env(Environment::Create()); |
| 84 std::string cr_source_root; | 83 std::string cr_source_root; |
| 84 FilePath path; |
| 85 if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) { | 85 if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) { |
| 86 path = FilePath(cr_source_root); | 86 path = FilePath(cr_source_root); |
| 87 if (PathExists(path)) { | 87 if (PathExists(path)) { |
| 88 *result = path; | 88 *result = path; |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 DLOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " | 91 DLOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " |
| 92 << "point to a directory."; | 92 << "point to a directory."; |
| 93 } | 93 } |
| 94 // On POSIX, unit tests execute two levels deep from the source root. | 94 // On POSIX, unit tests execute two levels deep from the source root. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 FilePath cache_dir( | 110 FilePath cache_dir( |
| 111 nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", ".cache")); | 111 nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", ".cache")); |
| 112 *result = cache_dir; | 112 *result = cache_dir; |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace base | 119 } // namespace base |
| OLD | NEW |