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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_experimental/lib/src/utils.dart ('k') | pkg/pathos/lib/path.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/pathos/README.md
diff --git a/pkg/pathos/README.md b/pkg/pathos/README.md
index e67fc5e0199066880a06460fb88de0d68173980e..1e50b2318e8bc68aa32afa457e0175f947ad2ebf 100644
--- a/pkg/pathos/README.md
+++ b/pkg/pathos/README.md
@@ -216,6 +216,44 @@ Removes a trailing extension from the last part of [path].
withoutExtension('path/to/foo.dart'); // -> 'path/to/foo'
+### String fromUri(Uri uri)
+
+Returns the path represented by [uri]. For POSIX and Windows styles, [uri] must
+be a `file:` URI. For the URL style, this will just convert [uri] to a string.
+
+ // POSIX
+ path.fromUri(Uri.parse('file:///path/to/foo'))
+ // -> '/path/to/foo'
+
+ // Windows
+ path.fromUri(Uri.parse('file:///C:/path/to/foo'))
+ // -> r'C:\path\to\foo'
+
+ // URL
+ path.fromUri(Uri.parse('http://dartlang.org/path/to/foo'))
+ // -> 'http://dartlang.org/path/to/foo'
+
+### Uri toUri(String path)
+
+Returns the URI that represents [path]. For POSIX and Windows styles, this will
+return a `file:` URI. For the URL style, this will just convert [path] to a
+[Uri].
+
+This will always convert relative paths to absolute ones before converting
+to a URI.
+
+ // POSIX
+ path.toUri('/path/to/foo')
+ // -> Uri.parse('file:///path/to/foo')
+
+ // Windows
+ path.toUri(r'C:\path\to\foo')
+ // -> Uri.parse('file:///C:/path/to/foo')
+
+ // URL
+ path.toUri('http://dartlang.org/path/to/foo')
+ // -> Uri.parse('http://dartlang.org/path/to/foo')
+
## The path.Builder class
In addition to the functions, path exposes a `path.Builder` class. This lets
« 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