public bool IgnoreDir(string workingDirectory, string fullDirectory)
{
string path;
workingDirectory = workingDirectory.Replace(Path.DirectorySeparatorChar, '/').TrimEnd('/');
path = fullDirectory.Replace(Path.DirectorySeparatorChar, '/').TrimEnd('/');
if (path.StartsWith(workingDirectory))
{
path = path.Substring(workingDirectory.Length);
}
else
{
throw new ArgumentException("fullDirectory must be a subdirectory of workingDirectory", "fullDirectory", null);
}
string dirPath = Path.GetDirectoryName(path).Replace(Path.DirectorySeparatorChar, '/').TrimEnd('/');
bool ignore = false;
foreach (Rule rule in rules)
{
if (rule.exclude != ignore)
{
if (rule.isDirectoryOnly && rule.pattern.IsMatch(dirPath))
ignore = rule.exclude;
}
}
return ignore;
}