| 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. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 * path separator do not have leading or terminating empty segments. | 116 * path separator do not have leading or terminating empty segments. |
| 117 * Other than that, the segments are just the result of splitting the | 117 * Other than that, the segments are just the result of splitting the |
| 118 * path on the path separator. | 118 * path on the path separator. |
| 119 * | 119 * |
| 120 * new Path('/a/b/c/d').segments() == ['a', 'b', 'c', d']; | 120 * new Path('/a/b/c/d').segments() == ['a', 'b', 'c', d']; |
| 121 * new Path(' foo bar //../') == [' foo bar ', '', '..']; | 121 * new Path(' foo bar //../') == [' foo bar ', '', '..']; |
| 122 */ | 122 */ |
| 123 List<String> segments(); | 123 List<String> segments(); |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Appends [finalSegment] to a path as a new segment. Adds a path separator |
| 127 * between the path and [finalSegment] if the path does not already end in |
| 128 * a path separator. The path is not canonicalized, and [finalSegment] may |
| 129 * contain path separators. |
| 130 */ |
| 131 Path append(String finalSegment); |
| 132 |
| 133 /** |
| 126 * Drops the final path separator and whatever follows it from this Path, | 134 * Drops the final path separator and whatever follows it from this Path, |
| 127 * and returns the resulting Path object. If the only path separator in | 135 * and returns the resulting Path object. If the only path separator in |
| 128 * this Path is the first character, returns '/' instead of the empty string. | 136 * this Path is the first character, returns '/' instead of the empty string. |
| 129 * If there is no path separator in the Path, returns the empty string. | 137 * If there is no path separator in the Path, returns the empty string. |
| 130 * | 138 * |
| 131 * new Path('../images/dot.gif').directoryPath == '../images' | 139 * new Path('../images/dot.gif').directoryPath == '../images' |
| 132 * new Path('/usr/geoffrey/www/').directoryPath == '/usr/geoffrey/www' | 140 * new Path('/usr/geoffrey/www/').directoryPath == '/usr/geoffrey/www' |
| 133 * new Path('lost_file_old').directoryPath == '' | 141 * new Path('lost_file_old').directoryPath == '' |
| 134 * new Path('/src').directoryPath == '/' | 142 * new Path('/src').directoryPath == '/' |
| 135 * Note: new Path('/D:/src').directoryPath == '/D:' | 143 * Note: new Path('/D:/src').directoryPath == '/D:' |
| 136 */ | 144 */ |
| 137 Path get directoryPath(); | 145 Path get directoryPath(); |
| 138 | 146 |
| 139 /** | 147 /** |
| 140 * The part of the path after the last path separator, or the entire path if | 148 * The part of the path after the last path separator, or the entire path if |
| 141 * it contains no path separator. | 149 * it contains no path separator. |
| 142 * | 150 * |
| 143 * new Path('images/DSC_0027.jpg).filename == 'DSC_0027.jpg' | 151 * new Path('images/DSC_0027.jpg).filename == 'DSC_0027.jpg' |
| 144 * new Path('users/fred/').filename == '' | 152 * new Path('users/fred/').filename == '' |
| 145 */ | 153 */ |
| 146 String get filename(); | 154 String get filename(); |
| 147 | 155 |
| 148 /** | 156 /** |
| 149 * The part of [filename] before the last '.', or the entire filename if it | 157 * The part of [filename] before the last '.', or the entire filename if it |
| 150 * contains no '.'. | 158 * contains no '.'. If [filename] is '.' or '..' it is unchanged. |
| 151 * | 159 * |
| 152 * new Path('/c:/My Documents/Heidi.txt').filenameWithoutExtension | 160 * new Path('/c:/My Documents/Heidi.txt').filenameWithoutExtension |
| 153 * would return 'Heidi'. | 161 * would return 'Heidi'. |
| 154 * new Path('not what I would call a path').filenameWithoutExtension | 162 * new Path('not what I would call a path').filenameWithoutExtension |
| 155 * would return 'not what I would call a path'. | 163 * would return 'not what I would call a path'. |
| 156 */ | 164 */ |
| 157 String get filenameWithoutExtension(); | 165 String get filenameWithoutExtension(); |
| 158 | 166 |
| 159 /** | 167 /** |
| 160 * The part of [filename] after the last '.', or '' if [filename] | 168 * The part of [filename] after the last '.', or '' if [filename] |
| 161 * contains no '.'. | 169 * contains no '.'. If [filename] is '.' or '..', returns ''. |
| 162 * | 170 * |
| 163 * new Path('tiger.svg').extension == 'svg' | 171 * new Path('tiger.svg').extension == 'svg' |
| 164 * new Path('/src/dart/dart_secrets').extension == '' | 172 * new Path('/src/dart/dart_secrets').extension == '' |
| 165 */ | 173 */ |
| 166 String get extension(); | 174 String get extension(); |
| 167 } | 175 } |
| OLD | NEW |