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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 /// | 359 /// |
360 /// // URL | 360 /// // URL |
361 /// path.toUri('http://dartlang.org/path/to/foo') | 361 /// path.toUri('http://dartlang.org/path/to/foo') |
362 /// // -> Uri.parse('http://dartlang.org/path/to/foo') | 362 /// // -> Uri.parse('http://dartlang.org/path/to/foo') |
363 /// | 363 /// |
364 /// If [path] is relative, a relative URI will be returned. | 364 /// If [path] is relative, a relative URI will be returned. |
365 /// | 365 /// |
366 /// path.toUri('path/to/foo') | 366 /// path.toUri('path/to/foo') |
367 /// // -> Uri.parse('path/to/foo') | 367 /// // -> Uri.parse('path/to/foo') |
368 Uri toUri(String path) => _context.toUri(path); | 368 Uri toUri(String path) => _context.toUri(path); |
| 369 |
| 370 /// Returns a terse, human-readable representation of [uri]. |
| 371 /// |
| 372 /// [uri] can be a [String] or a [Uri]. If it can be made relative to the |
| 373 /// current working directory, that's done. Otherwise, it's returned as-is. This |
| 374 /// gracefully handles non-`file:` URIs for [Style.posix] and [Style.windows]. |
| 375 /// |
| 376 /// The returned value is meant for human consumption, and may be either URI- |
| 377 /// or path-formatted. |
| 378 /// |
| 379 /// // POSIX at "/root/path" |
| 380 /// path.prettyUri('file:///root/path/a/b.dart'); // -> 'a/b.dart' |
| 381 /// path.prettyUri('http://dartlang.org/'); // -> 'http://dartlang.org' |
| 382 /// |
| 383 /// // Windows at "C:\root\path" |
| 384 /// path.prettyUri('file:///C:/root/path/a/b.dart'); // -> r'a\b.dart' |
| 385 /// path.prettyUri('http://dartlang.org/'); // -> 'http://dartlang.org' |
| 386 /// |
| 387 /// // URL at "http://dartlang.org/root/path" |
| 388 /// path.prettyUri('http://dartlang.org/root/path/a/b.dart'); |
| 389 /// // -> r'a/b.dart' |
| 390 /// path.prettyUri('file:///root/path'); // -> 'file:///root/path' |
| 391 String prettyUri(uri) => _context.prettyUri(uri); |
OLD | NEW |