Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * A Path, interpreted as a sequence of strings separated by forward slashes. | |
| 7 * Paths are immutable wrappers of a String, that offer member functions for | |
| 8 * useful path manipulations and queries. | |
| 9 */ | |
| 10 interface Path default _PathImpl { | |
| 11 const Path(String source); | |
|
Mads Ager (google)
2012/06/01 08:11:31
Please document the constructor. Maybe with a comm
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 12 | |
| 13 /** | |
| 14 * Creates a Path from a String that uses the native filesystem's conventions. | |
| 15 * On Windows, this converts '\' to '/', and adds a '/' before a drive letter. | |
| 16 */ | |
| 17 Path.fromNative(String source); | |
| 18 | |
| 19 /** | |
| 20 * Is this path the empty string? | |
| 21 */ | |
| 22 bool get isEmpty(); | |
| 23 | |
| 24 /** | |
| 25 * Does this path begin with '/'? | |
|
Mads Ager (google)
2012/06/01 08:11:31
It seems strange that the getter name is 'isAbsolu
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 26 */ | |
| 27 bool get isAbsolute(); | |
| 28 | |
| 29 /** | |
| 30 * Does this path end with '/'? | |
| 31 */ | |
| 32 bool get hasTrailingSlash(); | |
|
Mads Ager (google)
2012/06/01 08:11:31
I think I would prefer 'path separator' instead of
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 33 | |
| 34 /** | |
| 35 * Does this path contain no segments . or .., except leading .. segments, | |
|
Mads Ager (google)
2012/06/01 08:11:31
If you use the term segments here, maybe the initi
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 36 * and contain no consecutive path separators? | |
| 37 */ | |
| 38 bool get isCanonical(); | |
| 39 | |
| 40 /** | |
| 41 * Make a path canonical by dropping . segments, canceling .. segments with | |
|
Mads Ager (google)
2012/06/01 08:11:31
Ditto.
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 42 * preceding segments, if possible, and combining consecutive path separators. | |
| 43 */ | |
| 44 Path canonicalize(); | |
| 45 | |
| 46 /** | |
| 47 * Joins the relative path [further] to this path, which may be absolute | |
| 48 * or relative. Canonicalizes the path, to remove ., .., and //. | |
|
Mads Ager (google)
2012/06/01 08:11:31
Examples or a more thorough explanation would be g
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 49 */ | |
| 50 Path join(Path further); | |
| 51 | |
| 52 /** | |
| 53 * Joins the relative path [further] to this path, which may be absolute | |
| 54 * or relative. Canonicalizes the path, to remove ., .., and //. | |
| 55 * [further] may not contain '..' segments which would traverse into | |
| 56 * this path, so [further.canonicalize()] is checked that it does not | |
| 57 * begin with '..' | |
|
Mads Ager (google)
2012/06/01 08:11:31
I think examples would be good here. What happens
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 58 */ | |
| 59 Path safeJoin(Path further); | |
| 60 | |
| 61 /** | |
| 62 * Converts a path to a string using the native filesystem's conventions. | |
| 63 */ | |
| 64 String toNativePath(); | |
| 65 | |
| 66 /** | |
| 67 * Returns the path as a string. If this path is constructed using | |
| 68 * new Path() or new Path.fromNative() on a non-Windows system, the | |
| 69 * returned value is the original string argument to the constructor. | |
| 70 */ | |
| 71 String toString(); | |
| 72 | |
| 73 /** | |
| 74 * Gets the segments of a Path (the strings separated by /) | |
|
Mads Ager (google)
2012/06/01 08:11:31
Instead of the parenthesis you could have an examp
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 75 */ | |
| 76 List<String> segments(); | |
| 77 | |
| 78 /** | |
| 79 * Drops the final '/' and whatever follows it from this Path, and returns | |
|
Mads Ager (google)
2012/06/01 08:11:31
should we write out 'path separator' instead of '/
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 80 * the resulting Path object. If the only '/' in this Path is the first | |
| 81 * character, returns '/' instead of ''. If there is no '/' in the Path, | |
|
Mads Ager (google)
2012/06/01 08:11:31
Text is good. Examples is better. :)
Also in the
Bill Hesse
2012/06/15 14:23:08
Done.
| |
| 82 * returns ''. | |
| 83 */ | |
| 84 Path get directoryPath(); | |
| 85 | |
| 86 /** | |
| 87 * The part of the path after the last '/', or the entire path if it contains | |
| 88 * no '/'. | |
| 89 */ | |
| 90 String get filename(); | |
| 91 | |
| 92 /** | |
| 93 * The part of [filename] before the last '.', or the entire filename if it | |
| 94 * contains no '.'. | |
| 95 */ | |
| 96 String get filenameWithoutExtension(); | |
| 97 | |
| 98 /** | |
| 99 * The part of [filename] after the last '.', or '' if [filename] | |
| 100 * contains no '.'. | |
| 101 */ | |
| 102 String get extension(); | |
| 103 } | |
| 104 | |
| 105 class PathException implements Exception { | |
|
Bill Hesse
2012/06/15 14:23:08
Removed.
| |
| 106 const PathException([String this.message]); | |
| 107 String toString() => "PathException: $message"; | |
| 108 final String message; | |
| 109 } | |
| OLD | NEW |