mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using Newtonsoft.Json;
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
{
|
|
public class IgnoreStartsWith : ACompilationStep
|
|
{
|
|
private readonly string _prefix;
|
|
private readonly string _reason;
|
|
|
|
public IgnoreStartsWith(ACompiler compiler, string prefix) : base(compiler)
|
|
{
|
|
_prefix = prefix;
|
|
_reason = string.Format("Ignored because path starts with {0}", _prefix);
|
|
}
|
|
|
|
public override Directive Run(RawSourceFile source)
|
|
{
|
|
if (source.Path.StartsWith(_prefix))
|
|
{
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
result.Reason = _reason;
|
|
return result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
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; }
|
|
|
|
public ICompilationStep CreateStep(ACompiler compiler)
|
|
{
|
|
return new IgnoreStartsWith(compiler, Prefix);
|
|
}
|
|
}
|
|
}
|
|
} |