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

Unified Diff: mojo/public/dart/third_party/path/lib/src/internal_style.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
Index: mojo/public/dart/third_party/path/lib/src/internal_style.dart
diff --git a/mojo/public/dart/third_party/path/lib/src/internal_style.dart b/mojo/public/dart/third_party/path/lib/src/internal_style.dart
new file mode 100644
index 0000000000000000000000000000000000000000..549f95ba94b0b79cc4c6cd59b597bd7ba72529a9
--- /dev/null
+++ b/mojo/public/dart/third_party/path/lib/src/internal_style.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library path.internal_style;
+
+import 'context.dart';
+import 'style.dart';
+
+/// The internal interface for the [Style] type.
+///
+/// Users should be able to pass around instances of [Style] like an enum, but
+/// the members that [Context] uses should be hidden from them. Those members
+/// are defined on this class instead.
+abstract class InternalStyle extends Style {
+ /// The default path separator for this style.
+ ///
+ /// On POSIX, this is `/`. On Windows, it's `\`.
+ String get separator;
+
+ /// Returns whether [path] contains a separator.
+ bool containsSeparator(String path);
+
+ /// Returns whether [codeUnit] is the character code of a separator.
+ bool isSeparator(int codeUnit);
+
+ /// Returns whether this path component needs a separator after it.
+ ///
+ /// Windows and POSIX styles just need separators when the previous component
+ /// doesn't already end in a separator, but the URL always needs to place a
+ /// separator between the root and the first component, even if the root
+ /// already ends in a separator character. For example, to join "file://" and
+ /// "usr", an additional "/" is needed (making "file:///usr").
+ bool needsSeparator(String path);
+
+ /// Returns the number of characters of the root part.
+ ///
+ /// Returns 0 if the path is relative.
+ ///
+ /// If the path is root-relative, the root length is 1.
+ int rootLength(String path);
+
+ /// Gets the root prefix of [path] if path is absolute. If [path] is relative,
+ /// returns `null`.
+ String getRoot(String path) {
+ var length = rootLength(path);
+ if (length > 0) return path.substring(0, length);
+ return isRootRelative(path) ? path[0] : null;
+ }
+
+ /// Returns whether [path] is root-relative.
+ ///
+ /// If [path] is relative or absolute and not root-relative, returns `false`.
+ bool isRootRelative(String path);
+
+ /// Returns the path represented by [uri] in this style.
+ String pathFromUri(Uri uri);
+
+ /// Returns the URI that represents the relative path made of [parts].
+ Uri relativePathToUri(String path) {
+ var segments = context.split(path);
+
+ // Ensure that a trailing slash in the path produces a trailing slash in the
+ // URL.
+ if (isSeparator(path.codeUnitAt(path.length - 1))) segments.add('');
+ return new Uri(pathSegments: segments);
+ }
+
+ /// Returns the URI that represents [path], which is assumed to be absolute.
+ Uri absolutePathToUri(String path);
+}
« no previous file with comments | « mojo/public/dart/third_party/path/lib/src/context.dart ('k') | mojo/public/dart/third_party/path/lib/src/parsed_path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698