コード例 #1
0
ファイル: OpRecursiveDir.cs プロジェクト: mbbill/vs-chromium
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      // If we are the last operation, don't match
      if (operatorIndex == operators.Count - 1)
        return -1;

      // If we reach the end of the "path", or we are not on a path separator, don't match
      if (pathIndex == path.Length || !FileNameMatching.IsPathSeparator(path[pathIndex]))
        return -1;

      pathIndex++;

      while (pathIndex < path.Length) {
        var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
        if (result == path.Length)
          return result;

        // Look for next path separator in path
        var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
        if (nextPathIndex < 0)
          break;

        pathIndex = nextPathIndex + 1;
      }

      return -1;
    }
コード例 #2
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex)
 {
     var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
       if (kind == MatchKind.File && result == path.Length)
     return -1;
       return result;
 }
コード例 #3
0
ファイル: OpAsterisk.cs プロジェクト: zpublic/vs-chromium
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            // Heuristic: If last operator, there is a full match (since "*" at the
            // end matches everything)
            if (operatorIndex == operators.Count - 1)
            {
                if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0)
                {
                    return(path.Length);
                }
                return(-1);
            }

            // Heuristic for "*[a-z]+":
            // * if we are matching a file name and
            // * if there are not path separators after "pathIndex" and
            // * if the only operator after us is "OpText"
            // * then we only need to check that path end with the text.
            if (kind == MatchKind.File)
            {
                if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0)
                {
                    if (operatorIndex + 1 == operators.Count - 1)
                    {
                        var opText = operators[operatorIndex + 1] as OpText;
                        if (opText != null)
                        {
                            if (comparer.EndsWith(path, opText.Text))
                            {
                                var remaining = path.Length - pathIndex;
                                if (remaining >= opText.Text.Length)
                                {
                                    return(path.Length);
                                }
                            }
                            return(-1);
                        }
                    }
                }
            }

            // Full "*" semantics: any character except "/"
            for (var i = pathIndex; i < path.Length; i++)
            {
                // If we reach "/", move on to next operator
                if (FileNameMatching.IsPathSeparator(path[i]))
                {
                    return(Match(kind, comparer, operators, operatorIndex + 1, path, i));
                }

                var result = Match(kind, comparer, operators, operatorIndex + 1, path, i);
                if (result == path.Length)
                {
                    return(result);
                }
            }

            return(-1);
        }
コード例 #4
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
 {
     if (pathIndex < path.Length && path[pathIndex] == Path.DirectorySeparatorChar)
     {
         return(Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + 1));
     }
     return(-1);
 }
コード例 #5
0
ファイル: PathMatcher.cs プロジェクト: mbbill/vs-chromium
 private bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer) {
   // Note: Use a "for" loop to avoid allocation with "Any"
   for (var index = 0; index < _prePassOperators.Length; index++) {
     if (_prePassOperators[index].PrePassWontMatch(kind, path, comparer))
       return true;
   }
   return false;
 }
コード例 #6
0
ファイル: OpText.cs プロジェクト: mbbill/vs-chromium
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      var len = _text.Length;

      if (comparer.Compare(_text, 0, path, pathIndex, len) != 0)
        return -1;

      return Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + len);
    }
コード例 #7
0
ファイル: PathMatcher.cs プロジェクト: mbbill/vs-chromium
    public bool MatchFileName(RelativePath relativePath, IPathComparer comparer) {
      var path = relativePath.Value;
      CheckPath(path);

      if (PrePassWontMatch(MatchKind.File, path, comparer))
        return false;

      var result = BaseOperator.Match(MatchKind.File, comparer, Operators, 0, path, 0);
      return IsMatch(path, result);
    }
コード例 #8
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);

            if (kind == MatchKind.File && result == path.Length)
            {
                return(-1);
            }
            return(result);
        }
コード例 #9
0
        public bool MatchFileName(string path, IPathComparer comparer)
        {
            CheckPath(path);

              if (PrePassWontMatch(MatchKind.File, path, comparer))
            return false;

              var result = BaseOperator.Match(MatchKind.File, comparer, Operators, 0, path, 0);
              return IsMatch(path, result);
        }
コード例 #10
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            var len = _text.Length;

            if (String.Compare(_text, 0, path, pathIndex, len, comparer.Comparison) != 0)
            {
                return(-1);
            }

            return(Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + len));
        }
コード例 #11
0
 private bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     // Note: Use a "for" loop to avoid allocation with "Any"
     for (var index = 0; index < _prePassOperators.Length; index++)
     {
         if (_prePassOperators[index].PrePassWontMatch(kind, path, comparer))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #12
0
ファイル: PathMatcher.cs プロジェクト: lineCode/vs-chromium
        public bool MatchFileName(string path, IPathComparer comparer)
        {
            CheckPath(path);

            if (PrePassWontMatch(MatchKind.File, path, comparer))
            {
                return(false);
            }

            var result = BaseOperator.Match(MatchKind.File, comparer, Operators, 0, path, 0);

            return(IsMatch(path, result));
        }
コード例 #13
0
ファイル: BaseOperator.cs プロジェクト: mbbill/vs-chromium
    /// <summary>
    /// Returns -1 if "path" does not conform to the pattern defined by "operators"
    /// Returns the index of the first character "path" which does not match the pattern.
    /// This means that if "index" == "path.Length", the whole path matches the pattern.
    /// </summary>
    public static int Match(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      if (operatorIndex > operators.Count)
        throw new ArgumentException("operator index outside of bounds.", "operatorIndex");

      if (pathIndex > path.Length)
        throw new ArgumentException("path index outside of bounds.", "pathIndex");

      // If we reach past the last operator, it means "we matched until this point".
      if (operatorIndex == operators.Count)
        return pathIndex;

      return operators[operatorIndex].MatchWorker(kind, comparer, operators, operatorIndex, path, pathIndex);
    }
コード例 #14
0
ファイル: AnyPathMatcher.cs プロジェクト: mbbill/vs-chromium
    public bool MatchFileName(RelativePath relativePath, IPathComparer comparer) {
      if (relativePath.IsEmpty)
        throw new ArgumentNullException("relativePath");

      if (_fileExtensions.Contains(relativePath.Extension))
        return true;

      // Note: Use "for" loop to avoid allocation if using "Any()"
      for (var index = 0; index < _pathMatchers.Length; index++) {
        if (_pathMatchers[index].MatchFileName(relativePath, comparer))
          return true;
      }
      return false;
    }
コード例 #15
0
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      while (pathIndex < path.Length) {
        var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
        if (result >= 0)
          return result;

        // Look for next path separator in path
        var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
        if (nextPathIndex < 0)
          break;
        pathIndex = nextPathIndex + 1;
      }

      return -1;
    }
コード例 #16
0
        public bool MatchFileName(RelativePath relativePath, IPathComparer comparer)
        {
            var path = relativePath.Value;

            CheckPath(path);

            if (PrePassWontMatch(MatchKind.File, path, comparer))
            {
                return(false);
            }

            var result = BaseOperator.Match(MatchKind.File, comparer, Operators, 0, path, 0);

            return(IsMatch(path, result));
        }
コード例 #17
0
        public bool MatchFileName(string path, IPathComparer comparer)
        {
            if (path == null)
            throw new ArgumentNullException("path");

              if (_fileExtensions.Contains(Path.GetExtension(path)))
            return true;

              // Note: Use "for" loop to avoid allocation if using "Any()"
              for (var index = 0; index < _pathMatchers.Length; index++) {
            if (_pathMatchers[index].MatchFileName(path, comparer))
              return true;
              }
              return false;
        }
コード例 #18
0
ファイル: OpAsterisk.cs プロジェクト: mbbill/vs-chromium
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      // Heuristic: If last operator, there is a full match (since "*" at the
      // end matches everything)
      if (operatorIndex == operators.Count - 1) {
        if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0)
          return path.Length;
        return -1;
      }

      // Heuristic for "*[a-z]+":
      // * if we are matching a file name and
      // * if there are not path separators after "pathIndex" and
      // * if the only operator after us is "OpText"
      // * then we only need to check that path end with the text.
      if (kind == MatchKind.File) {
        if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0) {
          if (operatorIndex + 1 == operators.Count - 1) {
            var opText = operators[operatorIndex + 1] as OpText;
            if (opText != null) {
              if (comparer.EndsWith(path, opText.Text)) {
                var remaining = path.Length - pathIndex;
                if (remaining >= opText.Text.Length)
                  return path.Length;
              }
              return -1;
            }
          }
        }
      }

      // Full "*" semantics: any character except "/"
      for (var i = pathIndex; i < path.Length; i++) {
        // If we reach "/", move on to next operator
        if (FileNameMatching.IsPathSeparator(path[i]))
          return Match(kind, comparer, operators, operatorIndex + 1, path, i);

        var result = Match(kind, comparer, operators, operatorIndex + 1, path, i);
        if (result == path.Length)
          return result;
      }

      return -1;
    }
コード例 #19
0
        /// <summary>
        /// Returns -1 if "path" does not conform to the pattern defined by "operators"
        /// Returns the index of the first character "path" which does not match the pattern.
        /// This means that if "index" == "path.Length", the whole path matches the pattern.
        /// </summary>
        public static int Match(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            if (operatorIndex > operators.Count)
            {
                throw new ArgumentException("operator index outside of bounds.", "operatorIndex");
            }

            if (pathIndex > path.Length)
            {
                throw new ArgumentException("path index outside of bounds.", "pathIndex");
            }

            // If we reach past the last operator, it means "we matched until this point".
            if (operatorIndex == operators.Count)
            {
                return(pathIndex);
            }

            return(operators[operatorIndex].MatchWorker(kind, comparer, operators, operatorIndex, path, pathIndex));
        }
コード例 #20
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            while (pathIndex < path.Length)
            {
                var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
                if (result >= 0)
                {
                    return(result);
                }

                // Look for next path separator in path
                var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
                if (nextPathIndex < 0)
                {
                    break;
                }
                pathIndex = nextPathIndex + 1;
            }

            return(-1);
        }
コード例 #21
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            // Heuristic: If last operator, there is a full match (since "*" at the end matches everything)
              if (operatorIndex == operators.Count - 1)
            return path.Length;

              // Heuristic:
              // * if we are matching a file name
              // * if there are not path separators after "pathIndex"
              // * if the only operator after us is "OpText", and
              // * then we only need to check that path end with the text.
              if (kind == MatchKind.File) {
            if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0) {
              if (operatorIndex + 1 == operators.Count - 1) {
            var opText = operators[operatorIndex + 1] as OpText;
            if (opText != null) {
              if (path.EndsWith(opText.Text, comparer.Comparison)) {
                var remaining = path.Length - pathIndex;
                if (remaining >= opText.Text.Length)
                  return path.Length;
              }
              return -1;
            }
              }
            }
              }

              // Full "*" semantics (recursive...)
              for (var i = pathIndex; i < path.Length; i++) {
            // Stop at first path separator
            if (FileNameMatching.IsPathSeparator(path[i]))
              break;

            var result = Match(kind, comparer, operators, operatorIndex + 1, path, i);
            if (result == path.Length)
              return result;
              }

              return -1;
        }
コード例 #22
0
        public bool MatchFileName(RelativePath relativePath, IPathComparer comparer)
        {
            if (relativePath.IsEmpty)
            {
                throw new ArgumentNullException("relativePath");
            }

            if (_fileExtensions.Contains(relativePath.Extension))
            {
                return(true);
            }

            // Note: Use "for" loop to avoid allocation if using "Any()"
            for (var index = 0; index < _pathMatchers.Length; index++)
            {
                if (_pathMatchers[index].MatchFileName(relativePath, comparer))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #23
0
        public bool MatchFileName(string path, IPathComparer comparer)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if (_fileExtensions.Contains(Path.GetExtension(path)))
            {
                return(true);
            }

            // Note: Use "for" loop to avoid allocation if using "Any()"
            for (var index = 0; index < _pathMatchers.Length; index++)
            {
                if (_pathMatchers[index].MatchFileName(path, comparer))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #24
0
ファイル: OpRecursiveDir.cs プロジェクト: zpublic/vs-chromium
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            // If we are the last operation, don't match
            if (operatorIndex == operators.Count - 1)
            {
                return(-1);
            }

            // If we reach the end of the "path", or we are not on a path separator, don't match
            if (pathIndex == path.Length || !FileNameMatching.IsPathSeparator(path[pathIndex]))
            {
                return(-1);
            }

            pathIndex++;

            while (pathIndex < path.Length)
            {
                var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
                if (result == path.Length)
                {
                    return(result);
                }

                // Look for next path separator in path
                var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
                if (nextPathIndex < 0)
                {
                    break;
                }

                pathIndex = nextPathIndex + 1;
            }

            return(-1);
        }
コード例 #25
0
 private bool MatchFileRelativePath(IPathMatcher matcher, FileName fileName, IPathComparer comparer)
 {
     return(matcher.MatchFileName(fileName.RelativePath, comparer));
 }
コード例 #26
0
 public abstract int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex);
コード例 #27
0
ファイル: OpIsNoMatch.cs プロジェクト: mbbill/vs-chromium
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer) {
   return true;
 }
コード例 #28
0
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     return(true);
 }
コード例 #29
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
 {
     return(-1);
 }
コード例 #30
0
ファイル: OpText.cs プロジェクト: nick-chromium/vs-chromium
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     return path.IndexOf(_text, 0, path.Length, comparer.Comparison) < 0;
 }
コード例 #31
0
 public abstract int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex);
コード例 #32
0
ファイル: OpIsNoMatch.cs プロジェクト: mbbill/vs-chromium
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
   return -1;
 }
コード例 #33
0
ファイル: OpText.cs プロジェクト: mbbill/vs-chromium
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer) {
   return comparer.IndexOf(path, _text, 0, path.Length) < 0;
 }
コード例 #34
0
ファイル: IPathComparer.cs プロジェクト: zpublic/vs-chromium
 public static bool EndsWith(this IPathComparer comparer, string value, string searchText)
 {
     value      = (value ?? string.Empty);
     searchText = (searchText ?? string.Empty);
     return(comparer.IndexOf(value, searchText, 0, value.Length) == (value.Length - searchText.Length));
 }
コード例 #35
0
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     return(path.IndexOf(_text, 0, path.Length, comparer.Comparison) < 0);
 }
コード例 #36
0
 public bool MatchFileName(RelativePath path, IPathComparer comparer)
 {
     return(MatchRelativePath(path));
 }
コード例 #37
0
 public bool MatchDirectoryName(RelativePath path, IPathComparer comparer)
 {
     return(MatchRelativePath(path));
 }
コード例 #38
0
 public bool MatchFileName(RelativePath path, IPathComparer comparer)
 {
     return(false);
 }
コード例 #39
0
 public bool MatchDirectoryName(RelativePath path, IPathComparer comparer)
 {
     return(false);
 }
コード例 #40
0
        private bool MatchDirectoryRelativePath(IPathMatcher matcher, DirectoryName directoryName, IPathComparer comparer)
        {
            // "Chromium" root directories make it through here, skip them.
            if (directoryName.IsAbsoluteName)
            {
                return(false);
            }

            return(matcher.MatchDirectoryName(directoryName.RelativePathName.RelativeName, comparer));
        }
コード例 #41
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
   if (pathIndex < path.Length && path[pathIndex] == Path.DirectorySeparatorChar)
     return Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + 1);
   return -1;
 }