Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: runtime/bin/path.dart

Issue 10638002: Add methods to dart:io Path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove .concat method. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/path_impl.dart » ('j') | tests/standalone/io/path_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 /**
168 * The new Path formed by removing the last '.', and everything following
169 * it, from the filename part of this Path. Returns the path unchanged if
170 * the path ends in a path separator, or if there is no '.' in the filename.
171 * Returns the path unchanged if the filename is '.' or '..'.
172 */
173 String get pathWithoutExtension();
174
175 /**
160 * The part of [filename] after the last '.', or '' if [filename] 176 * The part of [filename] after the last '.', or '' if [filename]
161 * contains no '.'. 177 * contains no '.'. If [filename] is '.' or '..', returns ''.
162 * 178 *
163 * new Path('tiger.svg').extension == 'svg' 179 * new Path('tiger.svg').extension == 'svg'
164 * new Path('/src/dart/dart_secrets').extension == '' 180 * new Path('/src/dart/dart_secrets').extension == ''
165 */ 181 */
166 String get extension(); 182 String get extension();
167 } 183 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/path_impl.dart » ('j') | tests/standalone/io/path_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698