OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base_paths.h" | 5 #include "base/base_paths.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 NOTREACHED() << "Unable to resolve " << kSelfExe << "."; | 44 NOTREACHED() << "Unable to resolve " << kSelfExe << "."; |
45 return false; | 45 return false; |
46 } | 46 } |
47 *result = bin_dir; | 47 *result = bin_dir; |
48 return true; | 48 return true; |
49 #elif defined(OS_FREEBSD) | 49 #elif defined(OS_FREEBSD) |
50 int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; | 50 int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; |
51 char bin_dir[PATH_MAX + 1]; | 51 char bin_dir[PATH_MAX + 1]; |
52 size_t length = sizeof(bin_dir); | 52 size_t length = sizeof(bin_dir); |
53 int error = sysctl(name, 4, bin_dir, &length, NULL, 0); | 53 int error = sysctl(name, 4, bin_dir, &length, NULL, 0); |
54 if (error < 0 || length == 0 || strlen(bin_dir) == 0) { | 54 if (error < 0 || length == 0 || *bin_dir == '\0') { |
55 NOTREACHED() << "Unable to resolve path."; | 55 NOTREACHED() << "Unable to resolve path."; |
56 return false; | 56 return false; |
57 } | 57 } |
58 bin_dir[strlen(bin_dir)] = 0; | 58 bin_dir[strlen(bin_dir)] = 0; |
59 *result = FilePath(bin_dir); | 59 *result = FilePath(bin_dir); |
60 return true; | 60 return true; |
61 #elif defined(OS_SOLARIS) | 61 #elif defined(OS_SOLARIS) |
62 char bin_dir[PATH_MAX + 1]; | 62 char bin_dir[PATH_MAX + 1]; |
63 if (realpath(getexecname(), bin_dir) == NULL) { | 63 if (realpath(getexecname(), bin_dir) == NULL) { |
64 NOTREACHED() << "Unable to resolve " << getexecname() << "."; | 64 NOTREACHED() << "Unable to resolve " << getexecname() << "."; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 scoped_ptr<base::Environment> env(base::Environment::Create()); | 121 scoped_ptr<base::Environment> env(base::Environment::Create()); |
122 FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", | 122 FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", |
123 ".cache")); | 123 ".cache")); |
124 *result = cache_dir; | 124 *result = cache_dir; |
125 return true; | 125 return true; |
126 } | 126 } |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 } // namespace base | 130 } // namespace base |
OLD | NEW |