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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * A Path, which is a String interpreted as a sequence of path segments, | 8 * A Path, which is a String interpreted as a sequence of path segments, |
9 * which are strings, separated by forward slashes. | 9 * which are strings, separated by forward slashes. |
10 * Paths are immutable wrappers of a String, that offer member functions for | 10 * Paths are immutable wrappers of a String, that offer member functions for |
11 * useful path manipulations and queries. Joining of paths and normalization | 11 * useful path manipulations and queries. Joining of paths and normalization |
12 * interpret '.' and '..' in the usual way. | 12 * interpret '.' and '..' in the usual way. |
13 */ | 13 */ |
14 abstract class Path { | 14 abstract class Path { |
15 /** | 15 /** |
16 * Creates a Path from the String [source]. [source] is used as-is, so if | |
17 * the string does not consist of segments separated by forward slashes, the | |
18 * behavior may not be as expected. Paths are immutable. | |
19 */ | |
20 factory Path(String source) => new _Path(source); | |
21 | |
22 /** | |
23 * Creates a Path from a String that uses the native filesystem's conventions. | 16 * Creates a Path from a String that uses the native filesystem's conventions. |
24 * | 17 * |
25 * On Windows, this converts '\' to '/' and has special handling for drive | 18 * On Windows, this converts '\' to '/' and has special handling for drive |
26 * letters and shares. | 19 * letters and shares. |
27 * | 20 * |
28 * If the path contains a drive letter a '/' is added before the drive letter. | 21 * If the path starts with a drive letter, like 'C:', a '/' is added |
22 * before the drive letter. | |
29 * | 23 * |
30 * new Path.fromNative(r'c:\a\b').toString() == '/c:/a/b' | 24 * new Path(r'c:\a\b').toString() == '/c:/a/b' |
31 * | 25 * |
32 * A path starting with '/c:/' (or any other character instead of 'c') is | 26 * A path starting with '/c:/' (or any other character instead of 'c') is |
33 * treated specially. Backwards links ('..') cannot cancel the drive letter. | 27 * treated specially. Backwards links ('..') cannot cancel the drive letter. |
34 * | 28 * |
35 * If the path is a share path this is recorded in the Path object and | 29 * If the path is a share path this is recorded in the Path object and |
36 * maintained in operations on the Path object. | 30 * maintained in operations on the Path object. |
37 * | 31 * |
38 * var share = new Path.fromNative(r'\\share\a\b\c'); | 32 * var share = new Path(r'\\share\a\b\c'); |
39 * share.isWindowsShare == true | 33 * share.isWindowsShare == true |
40 * share.toString() == '/share/a/b/c' | 34 * share.toString() == '/share/a/b/c' |
41 * share.toNativePath() == r'\\share\a\b\c' | 35 * share.toNativePath() == r'\\share\a\b\c' |
42 * share.append('final').isWindowsShare == true | 36 * share.append('final').isWindowsShare == true |
43 */ | 37 */ |
38 factory Path(String source) => new _Path(source); | |
39 | |
40 // TODO(whesse): Remove this constructor, and change its uses to the default. | |
Mads Ager (google)
2013/01/14 12:33:34
I would be in favor of just removing it as part of
| |
41 /** | |
42 * Legacy method - this functionality has been moved to the default | |
43 * constructor. Will be removed in a subsequent changelist. | |
44 */ | |
44 factory Path.fromNative(String source) => new _Path.fromNative(source); | 45 factory Path.fromNative(String source) => new _Path.fromNative(source); |
45 | 46 |
46 /** | 47 /** |
48 * Creates a Path from the String [source]. [source] is used as-is, so if | |
49 * the string does not consist of segments separated by forward slashes, the | |
50 * behavior may not be as expected. Paths are immutable. | |
Mads Ager (google)
2013/01/14 12:33:34
"Paths are immutable." seems like a class comment
| |
51 */ | |
52 factory Path.raw(String source) => new _Path.raw(source); | |
53 | |
54 /** | |
47 * Is this path the empty string? | 55 * Is this path the empty string? |
48 */ | 56 */ |
49 bool get isEmpty; | 57 bool get isEmpty; |
50 | 58 |
51 /** | 59 /** |
52 * Is this path an absolute path, beginning with a path separator? | 60 * Is this path an absolute path, beginning with a path separator? |
53 */ | 61 */ |
54 bool get isAbsolute; | 62 bool get isAbsolute; |
55 | 63 |
56 /** | 64 /** |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 | 196 |
189 /** | 197 /** |
190 * The part of [filename] after the last '.', or '' if [filename] | 198 * The part of [filename] after the last '.', or '' if [filename] |
191 * contains no '.'. If [filename] is '.' or '..', returns ''. | 199 * contains no '.'. If [filename] is '.' or '..', returns ''. |
192 * | 200 * |
193 * new Path('tiger.svg').extension == 'svg' | 201 * new Path('tiger.svg').extension == 'svg' |
194 * new Path('/src/dart/dart_secrets').extension == '' | 202 * new Path('/src/dart/dart_secrets').extension == '' |
195 */ | 203 */ |
196 String get extension; | 204 String get extension; |
197 } | 205 } |
OLD | NEW |