mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
moved code and fixed critical bug.
This commit is contained in:
parent
b81b99b842
commit
9a796f31c7
@ -1,4 +1,6 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
|
||||
@ -7,21 +9,53 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
public class IgnoreSaveFiles : MO2CompilationStep
|
||||
{
|
||||
private AbsolutePath[] _profilePaths;
|
||||
private readonly bool _includeSaves;
|
||||
private readonly string _tag;
|
||||
private readonly AbsolutePath _sourcePath;
|
||||
|
||||
public IgnoreSaveFiles(ACompiler compiler) : base(compiler)
|
||||
{
|
||||
_tag = Consts.WABBAJACK_INCLUDE_SAVES;
|
||||
_sourcePath = compiler.SourcePath;
|
||||
string rootDirectory = (string)_sourcePath;
|
||||
|
||||
try
|
||||
{
|
||||
_includeSaves = File.Exists(((String)Directory.EnumerateFiles(rootDirectory, _tag).ToList().First())) ? true : false;
|
||||
}
|
||||
catch // Cant get a .First() if the list is empty, which it is when the files doesn't exist.
|
||||
{
|
||||
_includeSaves = false;
|
||||
}
|
||||
|
||||
|
||||
_profilePaths =
|
||||
MO2Compiler.SelectedProfiles.Select(p => MO2Compiler.SourcePath.Combine("profiles", p, "saves")).ToArray();
|
||||
}
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
if (!_profilePaths.Any(p => source.File.AbsoluteName.InFolder(p)))
|
||||
return null;
|
||||
if (_includeSaves)
|
||||
{
|
||||
foreach (var folderpath in _profilePaths)
|
||||
{
|
||||
if (!source.AbsolutePath.InFolder(folderpath)) continue;
|
||||
var result = source.EvolveTo<InlineFile>();
|
||||
result.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_profilePaths.Any(p => source.File.AbsoluteName.InFolder(p)))
|
||||
return null;
|
||||
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = "Ignore Save files";
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = "Ignore Save files";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
public class IncludeSavesOption: MO2CompilationStep
|
||||
{
|
||||
private readonly string _tag;
|
||||
|
||||
private readonly AbsolutePath _sourcePath;
|
||||
private AbsolutePath[] _profileSavePaths;
|
||||
private readonly bool _includeSaves;
|
||||
|
||||
public IncludeSavesOption(ACompiler compiler, string tag) : base(compiler)
|
||||
{
|
||||
_tag = tag;
|
||||
_sourcePath = compiler.SourcePath;
|
||||
string rootDirectory = (string)_sourcePath;
|
||||
_includeSaves = File.Exists(((String)Directory.EnumerateFiles(rootDirectory, _tag).ToList().First())) ? true : false;
|
||||
|
||||
_profileSavePaths =
|
||||
MO2Compiler.SelectedProfiles.Select(p => MO2Compiler.SourcePath.Combine("profiles", p, "saves")).ToArray();
|
||||
}
|
||||
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
if (_includeSaves)
|
||||
{
|
||||
foreach (var folderpath in _profileSavePaths)
|
||||
{
|
||||
if (!source.AbsolutePath.InFolder(folderpath)) continue;
|
||||
var result = source.EvolveTo<InlineFile>();
|
||||
result.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -426,7 +426,6 @@ namespace Wabbajack.Lib
|
||||
new IgnoreGameFilesIfGameFolderFilesExist(this),
|
||||
new IncludePropertyFiles(this),
|
||||
//new IncludeSteamWorkshopItems(this),
|
||||
new IncludeSavesOption(this,Consts.WABBAJACK_INCLUDE_SAVES),
|
||||
new IgnoreSaveFiles(this),
|
||||
new IgnoreStartsWith(this, "logs\\"),
|
||||
new IgnoreStartsWith(this, "downloads\\"),
|
||||
|
Loading…
Reference in New Issue
Block a user