OLD | NEW |
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 filenames; | 5 library filenames; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:uri'; | |
9 | 8 |
10 // TODO(ahe): This library should be replaced by a general | 9 // TODO(ahe): This library should be replaced by a general |
11 // path-munging library. | 10 // path-munging library. |
12 // | 11 // |
13 // See also: | 12 // See also: |
14 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx | 13 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx |
15 | 14 |
16 String nativeToUriPath(String filename) { | 15 String nativeToUriPath(String filename) { |
17 return new Path(filename).toString(); | 16 return new Path(filename).toString(); |
18 } | 17 } |
19 | 18 |
20 String uriPathToNative(String path) { | 19 String uriPathToNative(String path) { |
21 return new Path(path).toNativePath(); | 20 return new Path(path).toNativePath(); |
22 } | 21 } |
23 | 22 |
24 final Uri currentDirectory = new Uri.fromComponents( | 23 final Uri currentDirectory = new Uri( |
25 scheme: 'file', | 24 scheme: 'file', |
26 path: appendSlash(nativeToUriPath(new File('.').fullPathSync()))); | 25 path: appendSlash(nativeToUriPath(new File('.').fullPathSync()))); |
27 | 26 |
28 String appendSlash(String path) => path.endsWith('/') ? path : '$path/'; | 27 String appendSlash(String path) => path.endsWith('/') ? path : '$path/'; |
OLD | NEW |