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 <ostream> | 9 #include <ostream> |
10 #include <string> | 10 #include <string> |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 | 31 |
32 bool PathProviderPosix(int key, FilePath* result) { | 32 bool PathProviderPosix(int key, FilePath* result) { |
33 FilePath path; | 33 FilePath path; |
34 switch (key) { | 34 switch (key) { |
35 case base::FILE_EXE: | 35 case base::FILE_EXE: |
36 case base::FILE_MODULE: { // TODO(evanm): is this correct? | 36 case base::FILE_MODULE: { // TODO(evanm): is this correct? |
37 #if defined(OS_LINUX) | 37 #if defined(OS_LINUX) |
38 FilePath bin_dir; | 38 FilePath bin_dir; |
39 if (!file_util::ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { | 39 if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { |
40 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; | 40 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; |
41 return false; | 41 return false; |
42 } | 42 } |
43 *result = bin_dir; | 43 *result = bin_dir; |
44 return true; | 44 return true; |
45 #elif defined(OS_FREEBSD) | 45 #elif defined(OS_FREEBSD) |
46 int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; | 46 int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; |
47 char bin_dir[PATH_MAX + 1]; | 47 char bin_dir[PATH_MAX + 1]; |
48 size_t length = sizeof(bin_dir); | 48 size_t length = sizeof(bin_dir); |
49 // Upon return, |length| is the number of bytes written to |bin_dir| | 49 // Upon return, |length| is the number of bytes written to |bin_dir| |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return true; | 110 return true; |
111 } | 111 } |
112 case base::DIR_HOME: | 112 case base::DIR_HOME: |
113 *result = file_util::GetHomeDir(); | 113 *result = file_util::GetHomeDir(); |
114 return true; | 114 return true; |
115 } | 115 } |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
119 } // namespace base | 119 } // namespace base |
OLD | NEW |