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

Unified Diff: runtime/bin/builtin.dart

Issue 23199002: Fix absolute paths on Windows without a drive letter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 700eed70960f384972893ed7f3f6635c7b1176b8..a67038948b56c189c7f33838dc49c50982fe69ed 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -77,6 +77,7 @@ void _makeHttpRequest(String uri) {
// Are we running on Windows?
var _isWindows = false;
+var _workingWindowsDrivePrefix;
// The current working directory
var _workingDirectoryUri;
// The URI that the entry point script was loaded from. Remembered so that
@@ -123,8 +124,18 @@ _enforceTrailingSlash(uri) {
return uri;
}
+_extractDriveLetterPrefix(cwd) {
+ if (!_isWindows) {
+ return null;
+ }
+ if (cwd.length > 1 && cwd[1] == ':') {
+ return '/${cwd[0]}:';
+ }
+ return null;
+}
void _setWorkingDirectory(cwd) {
+ _workingWindowsDrivePrefix = _extractDriveLetterPrefix(cwd);
cwd = _sanitizeWindowsPath(cwd);
cwd = _enforceTrailingSlash(cwd);
_workingDirectoryUri = new Uri(scheme: 'file', path: cwd);
@@ -227,8 +238,19 @@ String _filePathFromFileUri(Uri uri) {
throw "URIs using the 'file:' scheme may not contain a host.";
}
- _logResolution('# Path: $uri -> ${uri.path}');
- return uri.path;
+ String path = uri.path;
+ _logResolution('# Path: $uri -> ${path}');
+ if (_isWindows && (path.length > 2) && path.startsWith('/') &&
+ (path[2] != ':')) {
zra 2013/08/14 16:38:12 Is this (path[2] != ':') checking that the path is
Cutch 2013/08/14 20:29:08 Done.
+ if (_workingWindowsDrivePrefix == null) {
+ throw 'Could not determine windows drive letter prefix.';
+ }
+ // Absolute path on Windows without a drive letter.
+ _logResolution('# Path: Windows absolute path needs a drive letter.'
+ ' Prepending $_workingWindowsDrivePrefix.');
+ path = '$_workingWindowsDrivePrefix$path';
+ }
+ return path;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698