Chromium Code Reviews| Index: bin/builtin.dart |
| =================================================================== |
| --- bin/builtin.dart (revision 4985) |
| +++ bin/builtin.dart (working copy) |
| @@ -3,8 +3,6 @@ |
| // BSD-style license that can be found in the LICENSE file. |
| #library("builtin"); |
| -#import("dart:nativewrappers"); |
| -#import("dart:coreimpl"); |
| void print(arg) { |
| _Logger._printString(arg.toString()); |
| @@ -22,3 +20,42 @@ |
| class _Logger { |
| static void _printString(String s) native "Logger_PrintString"; |
| } |
| + |
| + |
| +// Code to deal with URI resolution for the standalone binary. |
| +void _logResolution(String msg) { |
| + final enabled = false; |
| + if (enabled) { |
| + _Logger._printString(msg); |
| + } |
| +} |
| + |
| +// TODO(iposva): Make these private once the Dart API is fixed. |
|
ahe
2012/03/06 08:27:15
I'm curious, what needs to be fixed?
Ivan Posva
2012/03/07 07:46:53
Currently calling private methods through the Dart
ahe
2012/03/07 08:22:38
I guess that by Dart API, you are referring to the
|
| +String resolveScriptUri(String cwd, String scriptName) { |
| + _logResolution("# Current working directory: $cwd"); |
|
ahe
2012/03/06 08:27:15
This form of logging is expensive because you have
Ivan Posva
2012/03/07 07:46:53
Will be removed once I am convinced that this work
|
| + _logResolution("# ScriptName: $scriptName"); |
| + var base = new Uri(scheme: "file", path: "$cwd/"); |
|
ahe
2012/03/06 08:27:15
Appending / doesn't work for the root directory. S
Ivan Posva
2012/03/07 07:46:53
The problem with io.dart in leg is that it is curr
ahe
2012/03/07 08:22:38
I meant to refer to how I handle trailing "/" in d
|
| + var resolved = base.resolve(scriptName); |
| + _logResolution("# Resolved to: $resolved"); |
| + return resolved.toString(); |
| +} |
| + |
| +String resolveUri(String base, String userString) { |
| + var baseUri = new Uri.fromString(base); |
| + _logResolution("# Resolving: $userString from $base"); |
| + var resolved = baseUri.resolve(userString); |
| + _logResolution("# Resolved to: $resolved"); |
| + return resolved.toString(); |
| +} |
| + |
| +String filePathFromUri(String userUri) { |
| + var uri = new Uri.fromString(userUri); |
| + _logResolution("# Getting file path from: $uri"); |
| + if ("file" != uri.scheme) { |
| + // Only handling file URIs in standalone binary. |
| + _logResolution("# Not a file URI."); |
| + throw "Not a file uri: $uri"; |
| + } |
| + _logResolution("# Path: ${uri.path}"); |
| + return uri.path; |
| +} |