public IEnumerable <IFileSystemInfo> Walk(GlobNode node, GlobberSettings settings) { var context = new GlobVisitorContext(_environment, settings); node.Accept(this, context); return(context.Results); }
public static void Validate(string pattern, GlobNode node) { var previous = (GlobNode?)null; var current = node; while (current != null) { if (previous is RecursiveWildcardNode) { if (current is ParentDirectoryNode) { throw new NotSupportedException("Visiting a parent that is a recursive wildcard is not supported."); } } if (current is UncRootNode unc) { if (string.IsNullOrWhiteSpace(unc.Server)) { throw new IOException($"The pattern '{pattern}' has no server part specified."); } } previous = current; current = current.Next; } }
private static GlobNode RewriteUncRoot(string pattern, GlobNode root) { if (root is UncRootNode unc && string.IsNullOrWhiteSpace(unc.Server)) { var next = unc.Next; if (next == null) { throw new IOException($"The pattern '{pattern}' has no server part specified."); } else if (next is PathNode path && path.IsIdentifier) { // Rewrite the root node. return(new UncRootNode(path.GetPath()) { Next = next.Next, }); }