Skip to content

Commit

Permalink
Add a UNC examples to rootPrefix and split docs (flutter#73)
Browse files Browse the repository at this point in the history
Resolves some old TODOs. The related issue is closed:
dart-lang/sdk#7323

The change that closed the issues is
https://codereview.chromium.org/59133009

Add examples based on the tests added in that change.

Remove another TODO referencing the issue which I think is resolved.
  • Loading branch information
natebosch authored Apr 7, 2020
1 parent 4b8c83c commit 2d245ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ String dirname(String path) => context.dirname(path);
String extension(String path, [int level = 1]) =>
context.extension(path, level);

// TODO(nweiz): add a UNC example for Windows once issue 7323 is fixed.
/// Returns the root of [path], if it's absolute, or the empty string if it's
/// relative.
///
Expand All @@ -218,6 +217,7 @@ String extension(String path, [int level = 1]) =>
/// // Windows
/// p.rootPrefix(r'path\to\foo'); // -> ''
/// p.rootPrefix(r'C:\path\to\foo'); // -> r'C:\'
/// p.rootPrefix(r'\\server\share\a\b'); // -> r'\\server\share'
///
/// // URL
/// p.rootPrefix('path/to/foo'); // -> ''
Expand Down Expand Up @@ -295,7 +295,6 @@ String join(String part1,
/// For a fixed number of parts, [join] is usually terser.
String joinAll(Iterable<String> parts) => context.joinAll(parts);

// TODO(nweiz): add a UNC example for Windows once issue 7323 is fixed.
/// Splits [path] into its components using the current platform's [separator].
///
/// p.split('path/to/foo'); // -> ['path', 'to', 'foo']
Expand All @@ -312,6 +311,8 @@ String joinAll(Iterable<String> parts) => context.joinAll(parts);
///
/// // Windows
/// p.split(r'C:\path\to\foo'); // -> [r'C:\', 'path', 'to', 'foo']
/// p.split(r'\\server\share\path\to\foo');
/// // -> [r'\\server\share', 'foo', 'bar', 'baz']
///
/// // Browser
/// p.split('http://dartlang.org/path/to/foo');
Expand Down
5 changes: 3 additions & 2 deletions lib/src/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class Context {
String extension(String path, [int level = 1]) =>
_parse(path).extension(level);

// TODO(nweiz): add a UNC example for Windows once issue 7323 is fixed.
/// Returns the root of [path] if it's absolute, or an empty string if it's
/// relative.
///
Expand All @@ -169,6 +168,7 @@ class Context {
/// // Windows
/// context.rootPrefix(r'path\to\foo'); // -> ''
/// context.rootPrefix(r'C:\path\to\foo'); // -> r'C:\'
/// context.rootPrefix(r'\\server\share\a\b'); // -> r'\\server\share'
///
/// // URL
/// context.rootPrefix('path/to/foo'); // -> ''
Expand Down Expand Up @@ -296,7 +296,6 @@ class Context {
return buffer.toString();
}

// TODO(nweiz): add a UNC example for Windows once issue 7323 is fixed.
/// Splits [path] into its components using the current platform's
/// [separator]. Example:
///
Expand All @@ -314,6 +313,8 @@ class Context {
///
/// // Windows
/// context.split(r'C:\path\to\foo'); // -> [r'C:\', 'path', 'to', 'foo']
/// context.split(r'\\server\share\path\to\foo');
/// // -> [r'\\server\share', 'foo', 'bar', 'baz']
List<String> split(String path) {
final parsed = _parse(path);
// Filter out empty parts that exist due to multiple separators in a row.
Expand Down
2 changes: 0 additions & 2 deletions lib/src/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ abstract class Style {
/// Windows paths use `\` (backslash) as separators. Absolute paths start with
/// a drive letter followed by a colon (example, `C:`) or two backslashes
/// (`\\`) for UNC paths.
// TODO(rnystrom): The UNC root prefix should include the drive name too, not
// just the `\\`.
static final Style windows = WindowsStyle();

/// URLs aren't filesystem paths, but they're supported to make it easier to
Expand Down

0 comments on commit 2d245ec

Please sign in to comment.