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

Side by Side Diff: runtime/bin/builtin.dart

Issue 338783002: Remove another case of _sanitizeWindowsPath before Uri.file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library builtin; 5 library builtin;
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 // import 'root_library'; happens here from C Code 9 // import 'root_library'; happens here from C Code
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 var _entryPointScript; 159 var _entryPointScript;
160 // The directory to look in to resolve "package:" scheme URIs. 160 // The directory to look in to resolve "package:" scheme URIs.
161 var _packageRoot; 161 var _packageRoot;
162 162
163 163
164 void _setWindows() { 164 void _setWindows() {
165 _isWindows = true; 165 _isWindows = true;
166 } 166 }
167 167
168 168
169 _sanitizeWindowsPath(path) {
170 // For Windows we need to massage the paths a bit according to
171 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
172 //
173 // Convert
174 // C:\one\two\three
175 // to
176 // /C:/one/two/three
177
178 if (_isWindows == false) {
179 // Do nothing when not running Windows.
180 return path;
181 }
182
183 var fixedPath = "${path.replaceAll('\\', '/')}";
184
185 if ((path.length > 2) && (path[1] == ':')) {
186 // Path begins with a drive letter.
187 return '/$fixedPath';
188 }
189
190 return fixedPath;
191 }
192
193
194 _enforceTrailingSlash(uri) { 169 _enforceTrailingSlash(uri) {
195 // Ensure we have a trailing slash character. 170 // Ensure we have a trailing slash character.
196 if (!uri.endsWith('/')) { 171 if (!uri.endsWith('/')) {
197 return '$uri/'; 172 return '$uri/';
198 } 173 }
199 return uri; 174 return uri;
200 } 175 }
201 176
202 177
203 _extractDriveLetterPrefix(cwd) { 178 _extractDriveLetterPrefix(cwd) {
(...skipping 29 matching lines...) Expand all
233 _packageRoot = _workingDirectoryUri.resolveUri(new Uri.file(packageRoot)); 208 _packageRoot = _workingDirectoryUri.resolveUri(new Uri.file(packageRoot));
234 } 209 }
235 _logResolution('# Package root: $packageRoot -> $_packageRoot'); 210 _logResolution('# Package root: $packageRoot -> $_packageRoot');
236 } 211 }
237 212
238 213
239 String _resolveScriptUri(String scriptName) { 214 String _resolveScriptUri(String scriptName) {
240 if (_workingDirectoryUri == null) { 215 if (_workingDirectoryUri == null) {
241 throw 'No current working directory set.'; 216 throw 'No current working directory set.';
242 } 217 }
243 scriptName = _sanitizeWindowsPath(scriptName);
244 var scriptUri; 218 var scriptUri;
245 if (scriptName.startsWith("file:") || 219 if (scriptName.startsWith("file:") ||
246 scriptName.startsWith("http:") || 220 scriptName.startsWith("http:") ||
247 scriptName.startsWith("https:")) { 221 scriptName.startsWith("https:")) {
248 scriptUri = Uri.parse(scriptName); 222 scriptUri = Uri.parse(scriptName);
249 } else { 223 } else {
250 // Assume it's a file name. 224 // Assume it's a file name.
251 scriptUri = new Uri.file(scriptName); 225 scriptUri = new Uri.file(scriptName);
252 } 226 }
253 if (scriptUri.scheme != '') { 227 if (scriptUri.scheme != '') {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } else if (Platform.isWindows) { 426 } else if (Platform.isWindows) {
453 filename = '$name.dll'; 427 filename = '$name.dll';
454 } else { 428 } else {
455 _logResolution( 429 _logResolution(
456 'Native extensions not supported on ${Platform.operatingSystem}'); 430 'Native extensions not supported on ${Platform.operatingSystem}');
457 throw 'Native extensions not supported on ${Platform.operatingSystem}'; 431 throw 'Native extensions not supported on ${Platform.operatingSystem}';
458 } 432 }
459 433
460 return [path, filename, name]; 434 return [path, filename, name];
461 } 435 }
OLDNEW
« 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