Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: runtime/bin/loader.cc

Issue 2285223003: Fix native extension lookup (Closed)
Patch Set: Update test for error message change Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/extensions.cc ('k') | runtime/bin/utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/loader.cc
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc
index 122e851a302bb167d097aadd5480be963028b998..4d35728d228eeeffe234ec83ad1fd1bf6a310ac7 100644
--- a/runtime/bin/loader.cc
+++ b/runtime/bin/loader.cc
@@ -8,6 +8,7 @@
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "bin/extensions.h"
+#include "bin/file.h"
#include "bin/lockers.h"
#include "bin/utils.h"
@@ -261,12 +262,10 @@ static bool LibraryHandleError(Dart_Handle library, Dart_Handle error) {
}
-static bool IsWindowsHost() {
-#if defined(TARGET_OS_WINDOWS)
- return true;
-#else // defined(TARGET_OS_WINDOWS)
- return false;
-#endif // defined(TARGET_OS_WINDOWS)
+static bool PathContainsSeparator(const char* path) {
+ return (strchr(path, '/') != NULL) ||
+ ((strncmp(File::PathSeparator(), "/", 1) != 0) &&
+ (strstr(path, File::PathSeparator()) != NULL));
}
@@ -300,7 +299,6 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
return false;
}
-
if (result->tag == _Dart_kImportExtension) {
ASSERT(library_uri != Dart_Null());
Dart_Handle library = Dart_LookupLibrary(library_uri);
@@ -320,10 +318,10 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
lib_path = lib_uri;
}
const char* extension_path = DartUtils::RemoveScheme(extension_uri);
- if (strchr(extension_path, '/') != NULL ||
- (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) {
+ if (!File::IsAbsolutePath(extension_path) &&
+ PathContainsSeparator(extension_path)) {
loader->error_ = DartUtils::NewError(
- "Relative paths for dart extensions are not supported: '%s'",
+ "Native extension path must be absolute, or simply the file name: %s",
extension_path);
return false;
}
« no previous file with comments | « runtime/bin/extensions.cc ('k') | runtime/bin/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698