LCOV - code coverage report
Current view: top level - path-1.4.2/lib/src - style.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 4 6 66.7 %
Date: 2017-10-10 20:17:03 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2013, 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             : import 'context.dart';
       6             : import 'style/posix.dart';
       7             : import 'style/url.dart';
       8             : import 'style/windows.dart';
       9             : 
      10             : /// An enum type describing a "flavor" of path.
      11             : abstract class Style {
      12             :   /// POSIX-style paths use "/" (forward slash) as separators. Absolute paths
      13             :   /// start with "/". Used by UNIX, Linux, Mac OS X, and others.
      14             :   static final Style posix = new PosixStyle();
      15             : 
      16             :   /// Windows paths use "\" (backslash) as separators. Absolute paths start with
      17             :   /// a drive letter followed by a colon (example, "C:") or two backslashes
      18             :   /// ("\\") for UNC paths.
      19             :   // TODO(rnystrom): The UNC root prefix should include the drive name too, not
      20             :   // just the "\\".
      21             :   static final Style windows = new WindowsStyle();
      22             : 
      23             :   /// URLs aren't filesystem paths, but they're supported to make it easier to
      24             :   /// manipulate URL paths in the browser.
      25             :   ///
      26             :   /// URLs use "/" (forward slash) as separators. Absolute paths either start
      27             :   /// with a protocol and optional hostname (e.g. `http://dartlang.org`,
      28             :   /// `file://`) or with "/".
      29             :   static final Style url = new UrlStyle();
      30             : 
      31             :   /// The style of the host platform.
      32             :   ///
      33             :   /// When running on the command line, this will be [windows] or [posix] based
      34             :   /// on the host operating system. On a browser, this will be [url].
      35             :   static final Style platform = _getPlatformStyle();
      36             : 
      37             :   /// Gets the type of the host platform.
      38             :   static Style _getPlatformStyle() {
      39             :     // If we're running a Dart file in the browser from a `file:` URI,
      40             :     // [Uri.base] will point to a file. If we're running on the standalone,
      41             :     // it will point to a directory. We can use that fact to determine which
      42             :     // style to use.
      43          15 :     if (Uri.base.scheme != 'file') return Style.url;
      44          15 :     if (!Uri.base.path.endsWith('/')) return Style.url;
      45          15 :     if (new Uri(path: 'a/b').toFilePath() == 'a\\b') return Style.windows;
      46           5 :     return Style.posix;
      47             :   }
      48             : 
      49             :   /// The name of this path style. Will be "posix" or "windows".
      50             :   String get name;
      51             : 
      52             :   /// A [Context] that uses this style.
      53           0 :   Context get context => new Context(style: this);
      54             : 
      55             :   @Deprecated("Most Style members will be removed in path 2.0.")
      56             :   String get separator;
      57             : 
      58             :   @Deprecated("Most Style members will be removed in path 2.0.")
      59             :   Pattern get separatorPattern;
      60             : 
      61             :   @Deprecated("Most Style members will be removed in path 2.0.")
      62             :   Pattern get needsSeparatorPattern;
      63             : 
      64             :   @Deprecated("Most Style members will be removed in path 2.0.")
      65             :   Pattern get rootPattern;
      66             : 
      67             :   @Deprecated("Most Style members will be removed in path 2.0.")
      68             :   Pattern get relativeRootPattern;
      69             : 
      70             :   @Deprecated("Most style members will be removed in path 2.0.")
      71             :   String getRoot(String path);
      72             : 
      73             :   @Deprecated("Most style members will be removed in path 2.0.")
      74             :   String getRelativeRoot(String path);
      75             : 
      76             :   @Deprecated("Most style members will be removed in path 2.0.")
      77             :   String pathFromUri(Uri uri);
      78             : 
      79             :   @Deprecated("Most style members will be removed in path 2.0.")
      80             :   Uri relativePathToUri(String path);
      81             : 
      82             :   @Deprecated("Most style members will be removed in path 2.0.")
      83             :   Uri absolutePathToUri(String path);
      84             : 
      85           0 :   String toString() => name;
      86             : }

Generated by: LCOV version 1.13