| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/extensions.h" | 5 #include "bin/extensions.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/file.h" | 10 #include "bin/file.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 dir, | 31 dir, |
| 32 Platform::LibraryPrefix(), | 32 Platform::LibraryPrefix(), |
| 33 name, | 33 name, |
| 34 "-", | 34 "-", |
| 35 Platform::HostArchitecture(), // arm | 35 Platform::HostArchitecture(), // arm |
| 36 ".", | 36 ".", |
| 37 Platform::LibraryExtension(), // so | 37 Platform::LibraryExtension(), // so |
| 38 NULL, | 38 NULL, |
| 39 }; | 39 }; |
| 40 const char* library_file = Concatenate(path_components); | 40 const char* library_file = Concatenate(path_components); |
| 41 void* library_handle = LoadExtensionLibrary(library_file); | 41 void* library_handle = LoadLibrary(library_file); |
| 42 if (library_handle != NULL) { | 42 if (library_handle != NULL) { |
| 43 return library_handle; | 43 return library_handle; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Fall back on a library name without the suffix. | 47 // Fall back on a library name without the suffix. |
| 48 { | 48 { |
| 49 const char* path_components[] = { | 49 const char* path_components[] = { |
| 50 dir, | 50 dir, |
| 51 Platform::LibraryPrefix(), | 51 Platform::LibraryPrefix(), |
| 52 name, | 52 name, |
| 53 ".", | 53 ".", |
| 54 Platform::LibraryExtension(), // so | 54 Platform::LibraryExtension(), // so |
| 55 NULL, | 55 NULL, |
| 56 }; | 56 }; |
| 57 const char* library_file = Concatenate(path_components); | 57 const char* library_file = Concatenate(path_components); |
| 58 return LoadExtensionLibrary(library_file); | 58 return LoadLibrary(library_file); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 // IMPORTANT: In the absolute path case, do not extract the filename and search | 63 // IMPORTANT: In the absolute path case, do not extract the filename and search |
| 64 // for that by passing it to LoadExtensionLibrary. That can lead to confusion in | 64 // for that by passing it to LoadLibrary. That can lead to confusion in |
| 65 // which the absolute path is wrong, and a different version of the library is | 65 // which the absolute path is wrong, and a different version of the library is |
| 66 // loaded from the standard location. | 66 // loaded from the standard location. |
| 67 void* Extensions::ResolveAbsPathExtension(const char* extension_path) { | 67 void* Extensions::ResolveAbsPathExtension(const char* extension_path) { |
| 68 const char* last_slash = strrchr(extension_path, PathSeparator()) + 1; | 68 const char* last_slash = strrchr(extension_path, PathSeparator()) + 1; |
| 69 char* name = strdup(last_slash); | 69 char* name = strdup(last_slash); |
| 70 char* dir = StringUtils::StrNDup(extension_path, last_slash - extension_path); | 70 char* dir = StringUtils::StrNDup(extension_path, last_slash - extension_path); |
| 71 void* library_handle = MakePathAndResolve(dir, name); | 71 void* library_handle = MakePathAndResolve(dir, name); |
| 72 free(dir); | 72 free(dir); |
| 73 free(name); | 73 free(name); |
| 74 return library_handle; | 74 return library_handle; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 for (int i = 0; strings[i] != NULL; i++) { | 136 for (int i = 0; strings[i] != NULL; i++) { |
| 137 index += snprintf(result + index, size - index, "%s", strings[i]); | 137 index += snprintf(result + index, size - index, "%s", strings[i]); |
| 138 } | 138 } |
| 139 ASSERT(index == size - 1); | 139 ASSERT(index == size - 1); |
| 140 ASSERT(result[size - 1] == '\0'); | 140 ASSERT(result[size - 1] == '\0'); |
| 141 return result; | 141 return result; |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace bin | 144 } // namespace bin |
| 145 } // namespace dart | 145 } // namespace dart |
| OLD | NEW |