| 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 |
| 11 #include <limits.h> | 11 #include <limits.h> |
| 12 #include <stddef.h> | 12 #include <stddef.h> |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <ostream> | 15 #include <ostream> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/environment.h" | 18 #include "base/environment.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/nix/xdg_util.h" | 22 #include "base/nix/xdg_util.h" |
| 23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/process/process_metrics.h" | 24 #include "base/process/process_metrics.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 | 26 |
| 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) | 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; | 37 FilePath path; |
| 38 switch (key) { | 38 switch (key) { |
| 39 case FILE_EXE: | 39 case FILE_EXE: |
| 40 case FILE_MODULE: { // TODO(evanm): is this correct? | 40 case FILE_MODULE: { // TODO(evanm): is this correct? |
| (...skipping 19 matching lines...) Expand all Loading... |
| 60 *result = FilePath(FilePath::StringType(bin_dir, length - 1)); | 60 *result = FilePath(FilePath::StringType(bin_dir, length - 1)); |
| 61 return true; | 61 return true; |
| 62 #elif defined(OS_SOLARIS) | 62 #elif defined(OS_SOLARIS) |
| 63 char bin_dir[PATH_MAX + 1]; | 63 char bin_dir[PATH_MAX + 1]; |
| 64 if (realpath(getexecname(), bin_dir) == NULL) { | 64 if (realpath(getexecname(), bin_dir) == NULL) { |
| 65 NOTREACHED() << "Unable to resolve " << getexecname() << "."; | 65 NOTREACHED() << "Unable to resolve " << getexecname() << "."; |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 *result = FilePath(bin_dir); | 68 *result = FilePath(bin_dir); |
| 69 return true; | 69 return true; |
| 70 #elif defined(OS_OPENBSD) | 70 #elif defined(OS_OPENBSD) || defined(OS_AIX) |
| 71 // There is currently no way to get the executable path on OpenBSD | 71 // There is currently no way to get the executable path on OpenBSD |
| 72 char* cpath; | 72 char* cpath; |
| 73 if ((cpath = getenv("CHROME_EXE_PATH")) != NULL) | 73 if ((cpath = getenv("CHROME_EXE_PATH")) != NULL) |
| 74 *result = FilePath(cpath); | 74 *result = FilePath(cpath); |
| 75 else | 75 else |
| 76 *result = FilePath("/usr/local/chrome/chrome"); | 76 *result = FilePath("/usr/local/chrome/chrome"); |
| 77 return true; | 77 return true; |
| 78 #endif | 78 #endif |
| 79 } | 79 } |
| 80 case DIR_SOURCE_ROOT: { | 80 case DIR_SOURCE_ROOT: { |
| (...skipping 29 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 |