Summary

Class:ICSharpCode.SharpZipLib.Core.WindowsPathUtils
Assembly:ICSharpCode.SharpZipLib
File(s):C:\Users\Neil\Documents\Visual Studio 2015\Projects\icsharpcode\SZL_master\ICSharpCode.SharpZipLib\Core\WindowsPathUtils.cs
Covered lines:19
Uncovered lines:3
Coverable lines:22
Total lines:57
Line coverage:86.3%
Branch coverage:76.6%

Metrics

MethodCyclomatic ComplexitySequence CoverageBranch Coverage
.ctor()100
DropPathRoot(...)179077.42

File(s)

C:\Users\Neil\Documents\Visual Studio 2015\Projects\icsharpcode\SZL_master\ICSharpCode.SharpZipLib\Core\WindowsPathUtils.cs

#LineLine coverage
 1namespace ICSharpCode.SharpZipLib.Core
 2{
 3  /// <summary>
 4  /// WindowsPathUtils provides simple utilities for handling windows paths.
 5  /// </summary>
 6  public abstract class WindowsPathUtils
 7  {
 8    /// <summary>
 9    /// Initializes a new instance of the <see cref="WindowsPathUtils"/> class.
 10    /// </summary>
 011    internal WindowsPathUtils()
 12    {
 013    }
 14
 15    /// <summary>
 16    /// Remove any path root present in the path
 17    /// </summary>
 18    /// <param name="path">A <see cref="string"/> containing path information.</param>
 19    /// <returns>The path with the root removed if it was present; path otherwise.</returns>
 20    /// <remarks>Unlike the <see cref="System.IO.Path"/> class the path isnt otherwise checked for validity.</remarks>
 21    public static string DropPathRoot(string path)
 22    {
 6593023      string result = path;
 24
 6593025       if (!string.IsNullOrEmpty(path)) {
 6593026         if ((path[0] == '\\') || (path[0] == '/')) {
 27          // UNC name ?
 628           if ((path.Length > 1) && ((path[1] == '\\') || (path[1] == '/'))) {
 129            int index = 2;
 130            int elements = 2;
 31
 32            // Scan for two separate elements \\machine\share\restofpath
 1133             while ((index <= path.Length) &&
 1134              (((path[index] != '\\') && (path[index] != '/')) || (--elements > 0))) {
 1035              index++;
 36            }
 37
 138            index++;
 39
 140             if (index < path.Length) {
 141              result = path.Substring(index);
 142            } else {
 043              result = "";
 44            }
 45          }
 6592446         } else if ((path.Length > 1) && (path[1] == ':')) {
 1047          int dropCount = 2;
 1048           if ((path.Length > 2) && ((path[2] == '\\') || (path[2] == '/'))) {
 949            dropCount = 3;
 50          }
 1051          result = result.Remove(0, dropCount);
 52        }
 53      }
 6593054      return result;
 55    }
 56  }
 57}