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

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

Issue 16848002: Add toUri and fromUri functions to pathos. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Preserve trailing separators. 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
« no previous file with comments | « pkg/analyzer_experimental/lib/analyzer.dart ('k') | pkg/pathos/README.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 library utils;
5
6 import 'dart:io';
7
8 import 'package:pathos/path.dart' as pathos;
9
10 /// Converts a local path string to a `file:` [Uri].
11 Uri pathToFileUri(String pathString) {
12 pathString = pathos.absolute(pathString);
13 if (Platform.operatingSystem != 'windows') {
14 return Uri.parse('file://$pathString');
15 } else if (pathos.rootPrefix(pathString).startsWith('\\\\')) {
16 // Network paths become "file://hostname/path/to/file".
17 return Uri.parse('file:${pathString.replaceAll("\\", "/")}');
18 } else {
19 // Drive-letter paths become "file:///C:/path/to/file".
20 return Uri.parse('file:///${pathString.replaceAll("\\", "/")}');
21 }
22 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/analyzer.dart ('k') | pkg/pathos/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698