2019-12-04 01:26:26 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Newtonsoft.Json;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
|
|
|
|
public class IgnoreStartsWith : ACompilationStep
|
|
|
|
|
{
|
|
|
|
|
private readonly string _prefix;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
private readonly string _reason;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public IgnoreStartsWith(ACompiler compiler, string prefix) : base(compiler)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
_prefix = prefix;
|
|
|
|
|
_reason = string.Format("Ignored because path starts with {0}", _prefix);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 01:26:26 +00:00
|
|
|
|
public override async ValueTask<Directive> Run(RawSourceFile source)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
if (source.Path.StartsWith(_prefix))
|
|
|
|
|
{
|
|
|
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
|
result.Reason = _reason;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
2019-10-30 12:29:06 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
|
|
|
|
public override IState GetState()
|
|
|
|
|
{
|
|
|
|
|
return new State(_prefix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonObject("IgnoreStartsWith")]
|
|
|
|
|
public class State : IState
|
|
|
|
|
{
|
|
|
|
|
public State()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public State(string prefix)
|
|
|
|
|
{
|
|
|
|
|
Prefix = prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Prefix { get; set; }
|
|
|
|
|
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public ICompilationStep CreateStep(ACompiler compiler)
|
2019-10-31 02:24:42 +00:00
|
|
|
|
{
|
|
|
|
|
return new IgnoreStartsWith(compiler, Prefix);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
2019-12-04 01:26:26 +00:00
|
|
|
|
}
|