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: bin/builtin.dart

Issue 9614006: - Proper URI resolution when loading scripts from the standalone binary. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | « no previous file | bin/builtin_nolib.cc » ('j') | bin/main.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/builtin.dart
===================================================================
--- bin/builtin.dart (revision 5061)
+++ bin/builtin.dart (working copy)
@@ -1,10 +1,8 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// 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.
+String resolveScriptUri(String cwd, String scriptName) {
+ _logResolution("# Current working directory: $cwd");
+ _logResolution("# ScriptName: $scriptName");
+ var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/");
+ 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;
+}
« no previous file with comments | « no previous file | bin/builtin_nolib.cc » ('j') | bin/main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698