wabbajack/Wabbajack.Compiler/CompilationSteps/IgnorePathContains.cs

26 lines
808 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.Threading.Tasks;
using Wabbajack.DTOs;
using Wabbajack.DTOs.Directives;
2021-09-27 12:42:46 +00:00
namespace Wabbajack.Compiler.CompilationSteps
{
public class IgnorePathContains : ACompilationStep
{
private readonly string _pattern;
private readonly string _reason;
public IgnorePathContains(ACompiler compiler, string pattern) : base(compiler)
{
_pattern = $"\\{pattern.Trim('\\')}\\";
_reason = $"Ignored because path contains {_pattern}";
}
public override async ValueTask<Directive?> Run(RawSourceFile source)
{
2020-03-25 12:47:25 +00:00
if (!((string)source.Path).Contains(_pattern)) return null;
var result = source.EvolveTo<IgnoredDirectly>();
result.Reason = _reason;
return result;
}
}
2021-09-27 12:42:46 +00:00
}