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

Side by Side Diff: third_party/dart-packages/path/path/src/internal_style.dart

Issue 1063233004: Teach dart_package to understand the packages/ subdirectory (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove dart-packages Created 5 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 library path.internal_style;
6
7 import 'context.dart';
8 import 'style.dart';
9
10 /// The internal interface for the [Style] type.
11 ///
12 /// Users should be able to pass around instances of [Style] like an enum, but
13 /// the members that [Context] uses should be hidden from them. Those members
14 /// are defined on this class instead.
15 abstract class InternalStyle extends Style {
16 /// The default path separator for this style.
17 ///
18 /// On POSIX, this is `/`. On Windows, it's `\`.
19 String get separator;
20
21 /// Returns whether [path] contains a separator.
22 bool containsSeparator(String path);
23
24 /// Returns whether [codeUnit] is the character code of a separator.
25 bool isSeparator(int codeUnit);
26
27 /// Returns whether this path component needs a separator after it.
28 ///
29 /// Windows and POSIX styles just need separators when the previous component
30 /// doesn't already end in a separator, but the URL always needs to place a
31 /// separator between the root and the first component, even if the root
32 /// already ends in a separator character. For example, to join "file://" and
33 /// "usr", an additional "/" is needed (making "file:///usr").
34 bool needsSeparator(String path);
35
36 /// Returns the number of characters of the root part.
37 ///
38 /// Returns 0 if the path is relative.
39 ///
40 /// If the path is root-relative, the root length is 1.
41 int rootLength(String path);
42
43 /// Gets the root prefix of [path] if path is absolute. If [path] is relative,
44 /// returns `null`.
45 String getRoot(String path) {
46 var length = rootLength(path);
47 if (length > 0) return path.substring(0, length);
48 return isRootRelative(path) ? path[0] : null;
49 }
50
51 /// Returns whether [path] is root-relative.
52 ///
53 /// If [path] is relative or absolute and not root-relative, returns `false`.
54 bool isRootRelative(String path);
55
56 /// Returns the path represented by [uri] in this style.
57 String pathFromUri(Uri uri);
58
59 /// Returns the URI that represents the relative path made of [parts].
60 Uri relativePathToUri(String path) =>
61 new Uri(pathSegments: context.split(path));
62
63 /// Returns the URI that represents [path], which is assumed to be absolute.
64 Uri absolutePathToUri(String path);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698