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

Side by Side Diff: pkg/analyzer_experimental/lib/src/utils.dart

Issue 16019002: Merge the dart:uri library into dart:core and update the Uri class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final cleanup Created 7 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library utils; 4 library utils;
5 5
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:uri';
8 7
9 import 'package:pathos/path.dart' as pathos; 8 import 'package:pathos/path.dart' as pathos;
10 9
11 /// Converts a local path string to a `file:` [Uri]. 10 /// Converts a local path string to a `file:` [Uri].
12 Uri pathToFileUri(String pathString) { 11 Uri pathToFileUri(String pathString) {
13 pathString = pathos.absolute(pathString); 12 pathString = pathos.absolute(pathString);
14 if (Platform.operatingSystem != 'windows') { 13 if (Platform.operatingSystem != 'windows') {
15 return Uri.parse('file://$pathString'); 14 return Uri.parse('file://$pathString');
16 } else if (pathos.rootPrefix(pathString).startsWith('\\\\')) { 15 } else if (pathos.rootPrefix(pathString).startsWith('\\\\')) {
17 // Network paths become "file://hostname/path/to/file". 16 // Network paths become "file://hostname/path/to/file".
18 return Uri.parse('file:${pathString.replaceAll("\\", "/")}'); 17 return Uri.parse('file:${pathString.replaceAll("\\", "/")}');
19 } else { 18 } else {
20 // Drive-letter paths become "file:///C:/path/to/file". 19 // Drive-letter paths become "file:///C:/path/to/file".
21 return Uri.parse('file:///${pathString.replaceAll("\\", "/")}'); 20 return Uri.parse('file:///${pathString.replaceAll("\\", "/")}');
22 } 21 }
23 } 22 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698