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-09-27 12:42:46 +00:00
|
|
|
|
namespace Wabbajack.Compiler.CompilationSteps
|
2020-01-07 00:24:33 +00:00
|
|
|
|
{
|
|
|
|
|
public class IgnoreGameFilesIfGameFolderFilesExist : ACompilationStep
|
|
|
|
|
{
|
|
|
|
|
private readonly bool _gameFolderFilesExists;
|
2020-03-25 12:47:25 +00:00
|
|
|
|
private readonly AbsolutePath _gameFolder;
|
2020-01-07 00:24:33 +00:00
|
|
|
|
|
|
|
|
|
public IgnoreGameFilesIfGameFolderFilesExist(ACompiler compiler) : base(compiler)
|
|
|
|
|
{
|
2021-09-27 12:42:46 +00:00
|
|
|
|
_gameFolderFilesExists = _compiler._settings.Source.Combine(Consts.GameFolderFilesDir).DirectoryExists();
|
|
|
|
|
_gameFolder = _compiler._locator.GameLocation(_compiler._settings.Game);
|
2020-01-07 00:24:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-09 18:14:05 +00:00
|
|
|
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
2020-01-07 00:24:33 +00:00
|
|
|
|
{
|
2020-05-02 23:05:05 +00:00
|
|
|
|
if (!_gameFolderFilesExists) return null;
|
|
|
|
|
|
|
|
|
|
if (!source.AbsolutePath.InFolder(_gameFolder)) return null;
|
|
|
|
|
|
|
|
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
|
result.Reason = $"Ignoring game files because {Consts.GameFolderFilesDir} exists";
|
|
|
|
|
return result;
|
2020-01-07 00:24:33 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|