wabbajack/Wabbajack.Compiler/CompilationSteps/IgnoreGameFilesIfGameFolderFilesExist.cs

30 lines
1.0 KiB
C#
Raw Normal View History

2020-01-07 00:24:33 +00:00
using System.Threading.Tasks;
2021-09-27 12:42:46 +00:00
using Wabbajack.DTOs;
using Wabbajack.DTOs.Directives;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
2020-01-07 00:24:33 +00:00
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Compiler.CompilationSteps;
2020-01-07 00:24:33 +00:00
2021-10-23 16:51:17 +00:00
public class IgnoreGameFilesIfGameFolderFilesExist : ACompilationStep
{
private readonly AbsolutePath _gameFolder;
private readonly bool _gameFolderFilesExists;
2020-01-07 00:24:33 +00:00
2021-10-23 16:51:17 +00:00
public IgnoreGameFilesIfGameFolderFilesExist(ACompiler compiler) : base(compiler)
{
_gameFolderFilesExists = _compiler._settings.Source.Combine(Consts.GameFolderFilesDir).DirectoryExists();
_gameFolder = _compiler._locator.GameLocation(_compiler._settings.Game);
}
2021-10-23 16:51:17 +00:00
public override async ValueTask<Directive?> Run(RawSourceFile source)
{
if (!_gameFolderFilesExists) return null;
2021-10-23 16:51:17 +00:00
if (!source.AbsolutePath.InFolder(_gameFolder)) return null;
2020-01-07 00:24:33 +00:00
2021-10-23 16:51:17 +00:00
var result = source.EvolveTo<IgnoredDirectly>();
result.Reason = $"Ignoring game files because {Consts.GameFolderFilesDir} exists";
return result;
2020-01-07 00:24:33 +00:00
}
2021-10-23 16:51:17 +00:00
}