2019-10-31 02:24:42 +00:00
|
|
|
|
using System.Collections.Generic;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
|
|
|
|
public class IgnoreOtherProfiles : ACompilationStep
|
|
|
|
|
{
|
|
|
|
|
private readonly IEnumerable<string> _profiles;
|
|
|
|
|
|
|
|
|
|
public IgnoreOtherProfiles(Compiler compiler) : base(compiler)
|
|
|
|
|
{
|
|
|
|
|
_profiles = _compiler.SelectedProfiles
|
|
|
|
|
.Select(p => Path.Combine("profiles", p) + "\\")
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Directive Run(RawSourceFile source)
|
|
|
|
|
{
|
|
|
|
|
if (!source.Path.StartsWith("profiles\\")) return null;
|
|
|
|
|
if (_profiles.Any(profile => source.Path.StartsWith(profile))) return null;
|
|
|
|
|
var c = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
|
c.Reason = "File not for selected profiles";
|
|
|
|
|
return c;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
2019-10-31 02:24:42 +00:00
|
|
|
|
public override IState GetState()
|
|
|
|
|
{
|
|
|
|
|
return new State();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonObject("IgnoreOtherProfiles")]
|
|
|
|
|
public class State : IState
|
|
|
|
|
{
|
|
|
|
|
public ICompilationStep CreateStep(Compiler compiler)
|
|
|
|
|
{
|
|
|
|
|
return new IgnoreOtherProfiles(compiler);
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|