public bool IgnoreFile(string workingDirectory, string filePath)
{
string path;
workingDirectory = workingDirectory.Replace(Path.DirectorySeparatorChar, '/').TrimEnd('/');
path = filePath.Replace(Path.DirectorySeparatorChar, '/').TrimEnd('/');
if (path.StartsWith(workingDirectory))
{
path = path.Substring(workingDirectory.Length);
}
else
{
throw new ArgumentException("filePath must be a subpath of workingDirectory", "filePath", 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(path))
ignore = rule.exclude;
}
}
return ignore;
}