LCOV - code coverage report
Current view: top level - path-1.4.2/lib/src/style - posix.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 6 14 42.9 %
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 '../characters.dart' as chars;
       6             : import '../parsed_path.dart';
       7             : import '../internal_style.dart';
       8             : 
       9             : /// The style for POSIX paths.
      10             : class PosixStyle extends InternalStyle {
      11           5 :   PosixStyle();
      12             : 
      13             :   final name = 'posix';
      14             :   final separator = '/';
      15             :   final separators = const ['/'];
      16             : 
      17             :   // Deprecated properties.
      18             : 
      19             :   final separatorPattern = new RegExp(r'/');
      20             :   final needsSeparatorPattern = new RegExp(r'[^/]$');
      21             :   final rootPattern = new RegExp(r'^/');
      22             :   final relativeRootPattern = null;
      23             : 
      24           0 :   bool containsSeparator(String path) => path.contains('/');
      25             : 
      26           5 :   bool isSeparator(int codeUnit) => codeUnit == chars.SLASH;
      27             : 
      28             :   bool needsSeparator(String path) =>
      29          25 :       path.isNotEmpty && !isSeparator(path.codeUnitAt(path.length - 1));
      30             : 
      31             :   int rootLength(String path, {bool withDrive: false}) {
      32          15 :     if (path.isNotEmpty && isSeparator(path.codeUnitAt(0))) return 1;
      33             :     return 0;
      34             :   }
      35             : 
      36             :   bool isRootRelative(String path) => false;
      37             : 
      38             :   String getRelativeRoot(String path) => null;
      39             : 
      40             :   String pathFromUri(Uri uri) {
      41          20 :     if (uri.scheme == '' || uri.scheme == 'file') {
      42          10 :       return Uri.decodeComponent(uri.path);
      43             :     }
      44           0 :     throw new ArgumentError("Uri $uri must have scheme 'file:'.");
      45             :   }
      46             : 
      47             :   Uri absolutePathToUri(String path) {
      48           0 :     var parsed = new ParsedPath.parse(path, this);
      49           0 :     if (parsed.parts.isEmpty) {
      50             :       // If the path is a bare root (e.g. "/"), [components] will
      51             :       // currently be empty. We add two empty components so the URL constructor
      52             :       // produces "file:///", with a trailing slash.
      53           0 :       parsed.parts.addAll(["", ""]);
      54           0 :     } else if (parsed.hasTrailingSeparator) {
      55             :       // If the path has a trailing slash, add a single empty component so the
      56             :       // URI has a trailing slash as well.
      57           0 :       parsed.parts.add("");
      58             :     }
      59             : 
      60           0 :     return new Uri(scheme: 'file', pathSegments: parsed.parts);
      61             :   }
      62             : }

Generated by: LCOV version 1.13