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 /** | 5 /** |
6 * A Path, which is a String interpreted as a sequence of path segments, | 6 * A Path, which is a String interpreted as a sequence of path segments, |
7 * which are strings, separated by forward slashes. | 7 * which are strings, separated by forward slashes. |
8 * Paths are immutable wrappers of a String, that offer member functions for | 8 * Paths are immutable wrappers of a String, that offer member functions for |
9 * useful path manipulations and queries. Joining of paths and normalization | 9 * useful path manipulations and queries. Joining of paths and normalization |
10 * interpret '.' and '..' in the usual way. | 10 * interpret '.' and '..' in the usual way. |
11 */ | 11 */ |
12 abstract class Path { | 12 abstract class Path { |
13 /** | 13 /** |
14 * Creates a Path from the String [source]. [source] is used as-is, so if | 14 * Creates a Path from the String [source]. [source] is used as-is, so if |
15 * the string does not consist of segments separated by forward slashes, the | 15 * the string does not consist of segments separated by forward slashes, the |
16 * behavior may not be as expected. Paths are immutable. | 16 * behavior may not be as expected. Paths are immutable. |
17 */ | 17 */ |
18 factory Path(String source) => new _Path(source); | 18 factory Path(String source) => new _Path(source); |
19 | 19 |
20 /** | 20 /** |
21 * Creates a Path from a String that uses the native filesystem's conventions. | 21 * Creates a Path from a String that uses the native filesystem's conventions. |
22 * On Windows, this converts '\' to '/', and adds a '/' before a drive letter. | 22 * |
| 23 * On Windows, this converts '\' to '/' and has special handling for drive |
| 24 * letters and shares. |
| 25 * |
| 26 * If the path contains a drive letter a '/' is added before the drive letter. |
| 27 * |
| 28 * new Path.fromNative(r'c:\a\b').toString() == '/c:/a/b' |
| 29 * |
23 * A path starting with '/c:/' (or any other character instead of 'c') is | 30 * A path starting with '/c:/' (or any other character instead of 'c') is |
24 * treated specially. Backwards links ('..') cannot cancel the drive letter. | 31 * treated specially. Backwards links ('..') cannot cancel the drive letter. |
| 32 * |
| 33 * If the path is a share path this is recorded in the Path object and |
| 34 * maintained in operations on the Path object. |
| 35 * |
| 36 * var share = new Path.fromNative(r'\\share\a\b\c'); |
| 37 * share.isWindowsShare == true |
| 38 * share.toString() == '/share/a/b/c' |
| 39 * share.toNativePath() == r'\\share\a\b\c' |
| 40 * share.append('final').isWindowsShare == true |
25 */ | 41 */ |
26 factory Path.fromNative(String source) => new _Path.fromNative(source); | 42 factory Path.fromNative(String source) => new _Path.fromNative(source); |
27 | 43 |
28 /** | 44 /** |
29 * Is this path the empty string? | 45 * Is this path the empty string? |
30 */ | 46 */ |
31 bool get isEmpty; | 47 bool get isEmpty; |
32 | 48 |
33 /** | 49 /** |
34 * Is this path an absolute path, beginning with a path separator? | 50 * Is this path an absolute path, beginning with a path separator? |
35 */ | 51 */ |
36 bool get isAbsolute; | 52 bool get isAbsolute; |
37 | 53 |
38 /** | 54 /** |
| 55 * Is this path a Windows share path? |
| 56 */ |
| 57 bool get isWindowsShare; |
| 58 |
| 59 /** |
39 * Does this path end with a path separator? | 60 * Does this path end with a path separator? |
40 */ | 61 */ |
41 bool get hasTrailingSeparator; | 62 bool get hasTrailingSeparator; |
42 | 63 |
43 /** | 64 /** |
44 * Does this path contain no consecutive path separators, no segments that | 65 * Does this path contain no consecutive path separators, no segments that |
45 * are '.' unless the path is exactly '.', and segments that are '..' only | 66 * are '.' unless the path is exactly '.', and segments that are '..' only |
46 * as the leading segments on a relative path? | 67 * as the leading segments on a relative path? |
47 */ | 68 */ |
48 bool get isCanonical; | 69 bool get isCanonical; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 186 |
166 /** | 187 /** |
167 * The part of [filename] after the last '.', or '' if [filename] | 188 * The part of [filename] after the last '.', or '' if [filename] |
168 * contains no '.'. If [filename] is '.' or '..', returns ''. | 189 * contains no '.'. If [filename] is '.' or '..', returns ''. |
169 * | 190 * |
170 * new Path('tiger.svg').extension == 'svg' | 191 * new Path('tiger.svg').extension == 'svg' |
171 * new Path('/src/dart/dart_secrets').extension == '' | 192 * new Path('/src/dart/dart_secrets').extension == '' |
172 */ | 193 */ |
173 String get extension; | 194 String get extension; |
174 } | 195 } |
OLD | NEW |