wabbajack/Wabbajack.Lib/CompilationSteps/IncludeDummyESPs.cs

30 lines
1.0 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using Alphaleonis.Win32.Filesystem;
using Newtonsoft.Json;
2020-03-25 12:47:25 +00:00
using Wabbajack.Common;
namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeDummyESPs : ACompilationStep
{
public IncludeDummyESPs(ACompiler compiler) : base(compiler)
{
}
public override async ValueTask<Directive?> Run(RawSourceFile source)
{
2020-03-25 12:47:25 +00:00
if (source.AbsolutePath.Extension != Consts.ESP &&
source.AbsolutePath.Extension != Consts.ESM) return null;
2020-03-25 12:47:25 +00:00
var bsa = source.AbsolutePath.ReplaceExtension(Consts.BSA);
2020-04-15 11:53:49 +00:00
var bsaTextures = source.AbsolutePath.AppendToName(" - Textures").ReplaceExtension(Consts.BSA);
2020-03-25 12:47:25 +00:00
if (source.AbsolutePath.Size > 250 || !bsa.IsFile && !bsaTextures.IsFile) return null;
var inline = source.EvolveTo<InlineFile>();
2020-03-25 12:47:25 +00:00
inline.SourceDataID = await _compiler.IncludeFile(await source.AbsolutePath.ReadAllBytesAsync());
return inline;
}
}
}