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

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

Issue 19231002: Port dart:io Path tests to package:path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment to relative(path, from: from) Created 7 years, 5 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 | pkg/path/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 path package provides common operations for manipulating file paths: 3 The path package 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 Gets the part of [path] before the last separator. 67 Gets the part of [path] before the last separator.
68 68
69 path.dirname('path/to/foo.dart'); // -> 'path/to' 69 path.dirname('path/to/foo.dart'); // -> 'path/to'
70 path.dirname('path/to'); // -> 'to' 70 path.dirname('path/to'); // -> 'to'
71 71
72 Trailing separators are ignored. 72 Trailing separators are ignored.
73 73
74 builder.dirname('path/to/'); // -> 'path' 74 builder.dirname('path/to/'); // -> 'path'
75 75
76 If an absolute path contains no directories, only a root, then the root
77 is returned.
78
79 path.dirname('/'); // -> '/' (posix)
80 path.dirname('c:\'); // -> 'c:\' (windows)
81
82 If a relative path has no directories, then '.' is returned.
83 path.dirname('foo'); // -> '.'
84 path.dirname(''); // -> '.'
85
76 ### String extension(String path) 86 ### String extension(String path)
77 87
78 Gets the file extension of [path]: the portion of [basename] from the last 88 Gets the file extension of [path]: the portion of [basename] from the last
79 `.` to the end (including the `.` itself). 89 `.` to the end (including the `.` itself).
80 90
81 path.extension('path/to/foo.dart'); // -> '.dart' 91 path.extension('path/to/foo.dart'); // -> '.dart'
82 path.extension('path/to/foo'); // -> '' 92 path.extension('path/to/foo'); // -> ''
83 path.extension('path.to/foo'); // -> '' 93 path.extension('path.to/foo'); // -> ''
84 path.extension('path/to/foo.dart.js'); // -> '.js' 94 path.extension('path/to/foo.dart.js'); // -> '.js'
85 95
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 path.relative('/root/path/a/b.dart'); // -> 'a/b.dart' 203 path.relative('/root/path/a/b.dart'); // -> 'a/b.dart'
194 path.relative('/root/other.dart'); // -> '../other.dart' 204 path.relative('/root/other.dart'); // -> '../other.dart'
195 205
196 If the [from] argument is passed, [path] is made relative to that instead. 206 If the [from] argument is passed, [path] is made relative to that instead.
197 207
198 path.relative('/root/path/a/b.dart', 208 path.relative('/root/path/a/b.dart',
199 from: '/root/path'); // -> 'a/b.dart' 209 from: '/root/path'); // -> 'a/b.dart'
200 path.relative('/root/other.dart', 210 path.relative('/root/other.dart',
201 from: '/root/path'); // -> '../other.dart' 211 from: '/root/path'); // -> '../other.dart'
202 212
213 If [path] and/or [from] are relative paths, they are assumed to be relative
214 to the current directory.
215
203 Since there is no relative path from one drive letter to another on Windows, 216 Since there is no relative path from one drive letter to another on Windows,
204 this will return an absolute path in that case. 217 this will return an absolute path in that case.
205 218
206 // Windows 219 // Windows
207 path.relative(r'D:\other', from: r'C:\home'); // -> 'D:\other' 220 path.relative(r'D:\other', from: r'C:\home'); // -> 'D:\other'
208 221
209 // URL 222 // URL
210 path.relative('http://dartlang.org', from: 'http://pub.dartlang.org'); 223 path.relative('http://dartlang.org', from: 'http://pub.dartlang.org');
211 // -> 'http://dartlang.org' 224 // -> 'http://dartlang.org'
212 225
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 * It can accurately tell if a path is absolute based on drive-letters or UNC 397 * It can accurately tell if a path is absolute based on drive-letters or UNC
385 prefix. 398 prefix.
386 399
387 * It understands that "/foo" is not an absolute path on Windows. 400 * It understands that "/foo" is not an absolute path on Windows.
388 401
389 * It knows that "C:\foo\one.txt" and "c:/foo\two.txt" are two files in the 402 * It knows that "C:\foo\one.txt" and "c:/foo\two.txt" are two files in the
390 same directory. 403 same directory.
391 404
392 If you find a problem, surprise or something that's unclear, please don't 405 If you find a problem, surprise or something that's unclear, please don't
393 hesitate to [file a bug](http://dartbug.com/new) and let us know. 406 hesitate to [file a bug](http://dartbug.com/new) and let us know.
OLDNEW
« no previous file with comments | « no previous file | pkg/path/lib/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698