OLD | NEW |
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 // This is really Posix minus Mac. Mac code is in base_paths_mac.mm. | 5 // This is really Posix minus Mac. Mac code is in base_paths_mac.mm. |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 | 8 |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 #if defined(OS_FREEBSD) | 10 #if defined(OS_FREEBSD) |
11 #include <sys/param.h> | 11 #include <sys/param.h> |
12 #include <sys/sysctl.h> | 12 #include <sys/sysctl.h> |
13 #endif | 13 #endif |
14 | 14 |
15 #include "base/env_var.h" | 15 #include "base/environment.h" |
16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
21 #include "base/sys_string_conversions.h" | 21 #include "base/sys_string_conversions.h" |
22 #include "base/xdg_util.h" | 22 #include "base/xdg_util.h" |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 | 25 |
(...skipping 28 matching lines...) Expand all Loading... |
54 return false; | 54 return false; |
55 } | 55 } |
56 bin_dir[strlen(bin_dir)] = 0; | 56 bin_dir[strlen(bin_dir)] = 0; |
57 *result = FilePath(bin_dir); | 57 *result = FilePath(bin_dir); |
58 return true; | 58 return true; |
59 #endif | 59 #endif |
60 } | 60 } |
61 case base::DIR_SOURCE_ROOT: { | 61 case base::DIR_SOURCE_ROOT: { |
62 // Allow passing this in the environment, for more flexibility in build | 62 // Allow passing this in the environment, for more flexibility in build |
63 // tree configurations (sub-project builds, gyp --output_dir, etc.) | 63 // tree configurations (sub-project builds, gyp --output_dir, etc.) |
64 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); | 64 scoped_ptr<base::Environment> env(base::Environment::Create()); |
65 std::string cr_source_root; | 65 std::string cr_source_root; |
66 if (env->GetEnv("CR_SOURCE_ROOT", &cr_source_root)) { | 66 if (env->GetEnv("CR_SOURCE_ROOT", &cr_source_root)) { |
67 path = FilePath(cr_source_root); | 67 path = FilePath(cr_source_root); |
68 if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { | 68 if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { |
69 *result = path; | 69 *result = path; |
70 return true; | 70 return true; |
71 } else { | 71 } else { |
72 LOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " | 72 LOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " |
73 << "point to the correct source root directory."; | 73 << "point to the correct source root directory."; |
74 } | 74 } |
(...skipping 22 matching lines...) Expand all Loading... |
97 if (file_util::GetCurrentDirectory(&path) && | 97 if (file_util::GetCurrentDirectory(&path) && |
98 file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { | 98 file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { |
99 *result = path; | 99 *result = path; |
100 return true; | 100 return true; |
101 } | 101 } |
102 LOG(ERROR) << "Couldn't find your source root. " | 102 LOG(ERROR) << "Couldn't find your source root. " |
103 << "Try running from your chromium/src directory."; | 103 << "Try running from your chromium/src directory."; |
104 return false; | 104 return false; |
105 } | 105 } |
106 case base::DIR_USER_CACHE: | 106 case base::DIR_USER_CACHE: |
107 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); | 107 scoped_ptr<base::Environment> env(base::Environment::Create()); |
108 FilePath cache_dir(base::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", | 108 FilePath cache_dir(base::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", |
109 ".cache")); | 109 ".cache")); |
110 *result = cache_dir; | 110 *result = cache_dir; |
111 return true; | 111 return true; |
112 } | 112 } |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 } // namespace base | 116 } // namespace base |
OLD | NEW |