wabbajack/Wabbajack.Compiler/CompilationSteps/IgnorePathContains.cs

25 lines
739 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-10-23 16:51:17 +00:00
namespace Wabbajack.Compiler.CompilationSteps;
public class IgnorePathContains : ACompilationStep
{
2021-10-23 16:51:17 +00:00
private readonly string _pattern;
private readonly string _reason;
2021-10-23 16:51:17 +00:00
public IgnorePathContains(ACompiler compiler, string pattern) : base(compiler)
{
_pattern = $"\\{pattern.Trim('\\')}\\";
_reason = $"Ignored because path contains {_pattern}";
}
2021-10-23 16:51:17 +00:00
public override async ValueTask<Directive?> Run(RawSourceFile source)
{
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
}