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

Side by Side Diff: pkg/path/lib/path.dart

Issue 203673003: Allow [path.fromUri] to take a string as well as a URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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/src/context.dart » ('j') | pkg/path/test/posix_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// A comprehensive, cross-platform path manipulation library. 5 /// A comprehensive, cross-platform path manipulation library.
6 /// 6 ///
7 /// ## Installing ## 7 /// ## Installing ##
8 /// 8 ///
9 /// Use [pub][] to install this package. Add the following to your 9 /// Use [pub][] to install this package. Add the following to your
10 /// `pubspec.yaml` file. 10 /// `pubspec.yaml` file.
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 /// path.isWithin('/root/path', '/root/path/a'); // -> true 315 /// path.isWithin('/root/path', '/root/path/a'); // -> true
316 /// path.isWithin('/root/path', '/root/other'); // -> false 316 /// path.isWithin('/root/path', '/root/other'); // -> false
317 /// path.isWithin('/root/path', '/root/path') // -> false 317 /// path.isWithin('/root/path', '/root/path') // -> false
318 bool isWithin(String parent, String child) => _context.isWithin(parent, child); 318 bool isWithin(String parent, String child) => _context.isWithin(parent, child);
319 319
320 /// Removes a trailing extension from the last part of [path]. 320 /// Removes a trailing extension from the last part of [path].
321 /// 321 ///
322 /// withoutExtension('path/to/foo.dart'); // -> 'path/to/foo' 322 /// withoutExtension('path/to/foo.dart'); // -> 'path/to/foo'
323 String withoutExtension(String path) => _context.withoutExtension(path); 323 String withoutExtension(String path) => _context.withoutExtension(path);
324 324
325 /// Returns the path represented by [uri]. 325 /// Returns the path represented by [uri], which may be a [String] or a [Uri].
326 /// 326 ///
327 /// For POSIX and Windows styles, [uri] must be a `file:` URI. For the URL 327 /// For POSIX and Windows styles, [uri] must be a `file:` URI. For the URL
328 /// style, this will just convert [uri] to a string. 328 /// style, this will just convert [uri] to a string.
329 /// 329 ///
330 /// // POSIX 330 /// // POSIX
331 /// path.fromUri(Uri.parse('file:///path/to/foo')) 331 /// context.fromUri('file:///path/to/foo')
332 /// // -> '/path/to/foo' 332 /// // -> '/path/to/foo'
333 /// 333 ///
334 /// // Windows 334 /// // Windows
335 /// path.fromUri(Uri.parse('file:///C:/path/to/foo')) 335 /// context.fromUri('file:///C:/path/to/foo')
336 /// // -> r'C:\path\to\foo' 336 /// // -> r'C:\path\to\foo'
337 /// 337 ///
338 /// // URL 338 /// // URL
339 /// path.fromUri(Uri.parse('http://dartlang.org/path/to/foo')) 339 /// context.fromUri('http://dartlang.org/path/to/foo')
340 /// // -> 'http://dartlang.org/path/to/foo' 340 /// // -> 'http://dartlang.org/path/to/foo'
Bob Nystrom 2014/03/18 20:31:09 We should document and add an example that a relat
nweiz 2014/03/18 22:02:19 Done.
341 String fromUri(Uri uri) => _context.fromUri(uri); 341 String fromUri(uri) => _context.fromUri(uri);
342 342
343 /// Returns the URI that represents [path]. 343 /// Returns the URI that represents [path].
344 /// 344 ///
345 /// For POSIX and Windows styles, this will return a `file:` URI. For the URL 345 /// For POSIX and Windows styles, this will return a `file:` URI. For the URL
346 /// style, this will just convert [path] to a [Uri]. 346 /// style, this will just convert [path] to a [Uri].
347 /// 347 ///
348 /// // POSIX 348 /// // POSIX
349 /// path.toUri('/path/to/foo') 349 /// path.toUri('/path/to/foo')
350 /// // -> Uri.parse('file:///path/to/foo') 350 /// // -> Uri.parse('file:///path/to/foo')
351 /// 351 ///
352 /// // Windows 352 /// // Windows
353 /// path.toUri(r'C:\path\to\foo') 353 /// path.toUri(r'C:\path\to\foo')
354 /// // -> Uri.parse('file:///C:/path/to/foo') 354 /// // -> Uri.parse('file:///C:/path/to/foo')
355 /// 355 ///
356 /// // URL 356 /// // URL
357 /// path.toUri('http://dartlang.org/path/to/foo') 357 /// path.toUri('http://dartlang.org/path/to/foo')
358 /// // -> Uri.parse('http://dartlang.org/path/to/foo') 358 /// // -> Uri.parse('http://dartlang.org/path/to/foo')
359 /// 359 ///
360 /// If [path] is relative, a relative URI will be returned. 360 /// If [path] is relative, a relative URI will be returned.
361 /// 361 ///
362 /// path.toUri('path/to/foo') 362 /// path.toUri('path/to/foo')
363 /// // -> Uri.parse('path/to/foo') 363 /// // -> Uri.parse('path/to/foo')
364 Uri toUri(String path) => _context.toUri(path); 364 Uri toUri(String path) => _context.toUri(path);
OLDNEW
« no previous file with comments | « no previous file | pkg/path/lib/src/context.dart » ('j') | pkg/path/test/posix_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698