| 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 /// A comprehensive, cross-platform path manipulation library. | 5 /// A comprehensive, cross-platform path manipulation library. |
| 6 /// | 6 /// |
| 7 /// ## Installing ## | 7 /// ## Installing ## |
| 8 /// | 8 /// |
| 9 /// Use [pub][] to install this package. Add the following to your | 9 /// Use [pub][] to install this package. Add the following to your |
| 10 /// `pubspec.yaml` file. | 10 /// `pubspec.yaml` file. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 /// An internal context for the current OS so we can provide a straight | 72 /// An internal context for the current OS so we can provide a straight |
| 73 /// functional interface and not require users to create one. | 73 /// functional interface and not require users to create one. |
| 74 Context get _context { | 74 Context get _context { |
| 75 if (_cachedContext != null && Uri.base == _lastBaseUri) return _cachedContext; | 75 if (_cachedContext != null && Uri.base == _lastBaseUri) return _cachedContext; |
| 76 _lastBaseUri = Uri.base; | 76 _lastBaseUri = Uri.base; |
| 77 _cachedContext = new Context(); | 77 _cachedContext = new Context(); |
| 78 return _cachedContext; | 78 return _cachedContext; |
| 79 } | 79 } |
| 80 Context _cachedContext; | 80 Context _cachedContext; |
| 81 | 81 |
| 82 /// Returns the [Style] of the current context. |
| 83 /// |
| 84 /// This is the style that all top-level path functions will use. |
| 85 Style get style => _context.style; |
| 86 |
| 82 /// Gets the path to the current working directory. | 87 /// Gets the path to the current working directory. |
| 83 /// | 88 /// |
| 84 /// In the browser, this means the current URL, without the last file segment. | 89 /// In the browser, this means the current URL, without the last file segment. |
| 85 String get current { | 90 String get current { |
| 86 var uri = Uri.base; | 91 var uri = Uri.base; |
| 87 if (Style.platform == Style.url) { | 92 if (Style.platform == Style.url) { |
| 88 return uri.resolve('.').toString(); | 93 return uri.resolve('.').toString(); |
| 89 } else { | 94 } else { |
| 90 var path = uri.toFilePath(); | 95 var path = uri.toFilePath(); |
| 91 // Remove trailing '/' or '\'. | 96 // Remove trailing '/' or '\'. |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 /// | 355 /// |
| 351 /// // URL | 356 /// // URL |
| 352 /// path.toUri('http://dartlang.org/path/to/foo') | 357 /// path.toUri('http://dartlang.org/path/to/foo') |
| 353 /// // -> Uri.parse('http://dartlang.org/path/to/foo') | 358 /// // -> Uri.parse('http://dartlang.org/path/to/foo') |
| 354 /// | 359 /// |
| 355 /// If [path] is relative, a relative URI will be returned. | 360 /// If [path] is relative, a relative URI will be returned. |
| 356 /// | 361 /// |
| 357 /// path.toUri('path/to/foo') | 362 /// path.toUri('path/to/foo') |
| 358 /// // -> Uri.parse('path/to/foo') | 363 /// // -> Uri.parse('path/to/foo') |
| 359 Uri toUri(String path) => _context.toUri(path); | 364 Uri toUri(String path) => _context.toUri(path); |
| OLD | NEW |