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 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/path_utils.h" | 10 #include "base/android/path_utils.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 | 14 #include "base/process_util.h" |
15 namespace { | |
16 | |
17 const char kSelfExe[] = "/proc/self/exe"; | |
18 | |
19 } // namespace | |
20 | 15 |
21 namespace base { | 16 namespace base { |
22 | 17 |
23 bool PathProviderAndroid(int key, FilePath* result) { | 18 bool PathProviderAndroid(int key, FilePath* result) { |
24 switch (key) { | 19 switch (key) { |
25 case base::FILE_EXE: { | 20 case base::FILE_EXE: { |
26 char bin_dir[PATH_MAX + 1]; | 21 char bin_dir[PATH_MAX + 1]; |
27 int bin_dir_size = readlink(kSelfExe, bin_dir, PATH_MAX); | 22 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX); |
28 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { | 23 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { |
29 NOTREACHED() << "Unable to resolve " << kSelfExe << "."; | 24 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; |
30 return false; | 25 return false; |
31 } | 26 } |
32 bin_dir[bin_dir_size] = 0; | 27 bin_dir[bin_dir_size] = 0; |
33 *result = FilePath(bin_dir); | 28 *result = FilePath(bin_dir); |
34 return true; | 29 return true; |
35 } | 30 } |
36 case base::FILE_MODULE: { | 31 case base::FILE_MODULE: { |
37 // dladdr didn't work in Android as only the file name was returned. | 32 // dladdr didn't work in Android as only the file name was returned. |
38 NOTIMPLEMENTED(); | 33 NOTIMPLEMENTED(); |
39 return false; | 34 return false; |
(...skipping 26 matching lines...) Expand all Loading... |
66 default: { | 61 default: { |
67 // Note: the path system expects this function to override the default | 62 // Note: the path system expects this function to override the default |
68 // behavior. So no need to log an error if we don't support a given | 63 // behavior. So no need to log an error if we don't support a given |
69 // path. The system will just use the default. | 64 // path. The system will just use the default. |
70 return false; | 65 return false; |
71 } | 66 } |
72 } | 67 } |
73 } | 68 } |
74 | 69 |
75 } // namespace base | 70 } // namespace base |
OLD | NEW |