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

Side by Side Diff: pkg/pathos/README.md

Issue 16848002: Add toUri and fromUri functions to pathos. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Preserve trailing separators. Created 7 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 | « pkg/analyzer_experimental/lib/src/utils.dart ('k') | pkg/pathos/lib/path.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 A comprehensive, cross-platform path manipulation library for Dart. 1 A comprehensive, cross-platform path manipulation library for Dart.
2 2
3 The pathos library provides common operations for manipulating file paths: 3 The pathos library provides common operations for manipulating file paths:
4 joining, splitting, normalizing, etc. 4 joining, splitting, normalizing, etc.
5 5
6 We've tried very hard to make this library do the "right" thing on whatever 6 We've tried very hard to make this library do the "right" thing on whatever
7 platform you run it on. When you use the top-level functions, it will assume the 7 platform you run it on. When you use the top-level functions, it will assume the
8 current platform's path style and work with that. If you want to specifically 8 current platform's path style and work with that. If you want to specifically
9 work with paths of a specific style, you can construct a `path.Builder` for that 9 work with paths of a specific style, you can construct a `path.Builder` for that
10 style. 10 style.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // URL 209 // URL
210 path.relative('http://dartlang.org', from: 'http://pub.dartlang.org'); 210 path.relative('http://dartlang.org', from: 'http://pub.dartlang.org');
211 // -> 'http://dartlang.org' 211 // -> 'http://dartlang.org'
212 212
213 ### String withoutExtension(String path) 213 ### String withoutExtension(String path)
214 214
215 Removes a trailing extension from the last part of [path]. 215 Removes a trailing extension from the last part of [path].
216 216
217 withoutExtension('path/to/foo.dart'); // -> 'path/to/foo' 217 withoutExtension('path/to/foo.dart'); // -> 'path/to/foo'
218 218
219 ### String fromUri(Uri uri)
220
221 Returns the path represented by [uri]. For POSIX and Windows styles, [uri] must
222 be a `file:` URI. For the URL style, this will just convert [uri] to a string.
223
224 // POSIX
225 path.fromUri(Uri.parse('file:///path/to/foo'))
226 // -> '/path/to/foo'
227
228 // Windows
229 path.fromUri(Uri.parse('file:///C:/path/to/foo'))
230 // -> r'C:\path\to\foo'
231
232 // URL
233 path.fromUri(Uri.parse('http://dartlang.org/path/to/foo'))
234 // -> 'http://dartlang.org/path/to/foo'
235
236 ### Uri toUri(String path)
237
238 Returns the URI that represents [path]. For POSIX and Windows styles, this will
239 return a `file:` URI. For the URL style, this will just convert [path] to a
240 [Uri].
241
242 This will always convert relative paths to absolute ones before converting
243 to a URI.
244
245 // POSIX
246 path.toUri('/path/to/foo')
247 // -> Uri.parse('file:///path/to/foo')
248
249 // Windows
250 path.toUri(r'C:\path\to\foo')
251 // -> Uri.parse('file:///C:/path/to/foo')
252
253 // URL
254 path.toUri('http://dartlang.org/path/to/foo')
255 // -> Uri.parse('http://dartlang.org/path/to/foo')
256
219 ## The path.Builder class 257 ## The path.Builder class
220 258
221 In addition to the functions, path exposes a `path.Builder` class. This lets 259 In addition to the functions, path exposes a `path.Builder` class. This lets
222 you configure the root directory and path style that paths are built using 260 you configure the root directory and path style that paths are built using
223 explicitly instead of assuming the current working directory and host OS's path 261 explicitly instead of assuming the current working directory and host OS's path
224 style. 262 style.
225 263
226 You won't often use this, but it can be useful if you do a lot of path 264 You won't often use this, but it can be useful if you do a lot of path
227 manipulation relative to some root directory. 265 manipulation relative to some root directory.
228 266
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 * It can accurately tell if a path is absolute based on drive-letters or UNC 384 * It can accurately tell if a path is absolute based on drive-letters or UNC
347 prefix. 385 prefix.
348 386
349 * It understands that "/foo" is not an absolute path on Windows. 387 * It understands that "/foo" is not an absolute path on Windows.
350 388
351 * It knows that "C:\foo\one.txt" and "c:/foo\two.txt" are two files in the 389 * It knows that "C:\foo\one.txt" and "c:/foo\two.txt" are two files in the
352 same directory. 390 same directory.
353 391
354 If you find a problem, surprise or something that's unclear, please don't 392 If you find a problem, surprise or something that's unclear, please don't
355 hesitate to [file a bug](http://dartbug.com/new) and let us know. 393 hesitate to [file a bug](http://dartbug.com/new) and let us know.
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/utils.dart ('k') | pkg/pathos/lib/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698