mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #1371 from EzioTheDeadPoet/single_file_tagging
added file tagging support
This commit is contained in:
commit
f5c3b8003d
@ -136,6 +136,8 @@ You can create an empty `tagfile` with no extention in any folder you want to ap
|
||||
| `WABBAJACK_INCLUDE` | All files in this folder will be inlined into the `.wabbajack` file | |
|
||||
| `WABBAJACK_NOMATCH_INCLUDE` | All files in this folder will be inlined into the `.wabbajack` file even if Wabbajack did not found a match for them. | Useful for generated files.|
|
||||
| `WABBAJACK_IGNORE` | All files in this folder will be ignored by Wabbajack and therefore not be put into into the `.wabbajack` file. | Useful for tools or other things outside a mod you don't want/need reproduced on a users machine. Handle with care since excluded stuff can potentially break a setup.\* |
|
||||
| `WABBAJACK_NOMATCH_INCLUDE_FILES.txt` | All files listed in this file will be included in the `.wabbajack` file. | Every file needs to be in the same folder as the tag file. Every file need to be written into a new line. Every file needs to be added with its file extension.|
|
||||
| `WABBAJACK_IGNORE_FILES.txt` | All files listed in this file will be ignored by Wabbajack and not included in the `.wabbajack` file. | Every file needs to be in the same folder as the tag file. Every file need to be written into a new line. Every file needs to be added with its file extension.|
|
||||
| `WABBAJACK_INCLUDE_SAVES` | When this file exists Wabbajack will include your save files in the `.wabbajack` file.||
|
||||
|
||||
\*It will finish the installation of a modlist, but the installed list might not run if you excluded a crutial part of it.
|
||||
|
@ -47,6 +47,8 @@ namespace Wabbajack.Common
|
||||
public static string WABBAJACK_ALWAYS_DISABLE = "WABBAJACK_ALWAYS_DISABLE";
|
||||
public static string WABBAJACK_NOMATCH_INCLUDE = "WABBAJACK_NOMATCH_INCLUDE";
|
||||
public static string WABBAJACK_IGNORE = "WABBAJACK_IGNORE";
|
||||
public static string WABBAJACK_NOMATCH_INCLUDE_FILES = "WABBAJACK_NOMATCH_INCLUDE_FILES.txt";
|
||||
public static string WABBAJACK_IGNORE_FILES = "WABBAJACK_IGNORE_FILES.txt";
|
||||
public static string WABBAJACK_INCLUDE_SAVES = "WABBAJACK_INCLUDE_SAVES";
|
||||
|
||||
public static string GAME_PATH_MAGIC_BACK = "{--||GAME_PATH_MAGIC_BACK||--}";
|
||||
|
61
Wabbajack.Lib/CompilationSteps/IgnoreTaggedFiles.cs
Normal file
61
Wabbajack.Lib/CompilationSteps/IgnoreTaggedFiles.cs
Normal file
@ -0,0 +1,61 @@
|
||||
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 IgnoreTaggedFiles : ACompilationStep
|
||||
{
|
||||
private readonly List<AbsolutePath> _ignoreList = new List<AbsolutePath>();
|
||||
private List<AbsolutePath> _tagFiles;
|
||||
private readonly string _tag;
|
||||
private readonly ACompiler _aCompiler;
|
||||
private readonly AbsolutePath _sourcePath;
|
||||
private readonly string _reason;
|
||||
|
||||
public IgnoreTaggedFiles(ACompiler compiler, string tag) : base(compiler)
|
||||
{
|
||||
_aCompiler = (ACompiler)compiler;
|
||||
_sourcePath = _aCompiler.SourcePath;
|
||||
_tag = tag;
|
||||
string rootDirectory = (string)_sourcePath;
|
||||
|
||||
_reason = $"Ignored because folder was tagged with {_tag}";
|
||||
|
||||
_tagFiles = Directory.EnumerateFiles(rootDirectory, _tag, SearchOption.AllDirectories)
|
||||
.Select(str => (AbsolutePath)str)
|
||||
.ToList();
|
||||
|
||||
foreach (var tagFile in _tagFiles)
|
||||
{
|
||||
_ignoreList.Add(tagFile);
|
||||
string[] taggedFiles = File.ReadAllLines((String)tagFile);
|
||||
foreach (var taggedFile in taggedFiles)
|
||||
{
|
||||
_ignoreList.Add((AbsolutePath)(tagFile.ToString()
|
||||
.Replace(_tag,taggedFile)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
foreach (var folderpath in _ignoreList)
|
||||
{
|
||||
if (!source.AbsolutePath.InFolder(folderpath)) continue;
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = _reason;
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
58
Wabbajack.Lib/CompilationSteps/IncludeTaggedFiles.cs
Normal file
58
Wabbajack.Lib/CompilationSteps/IncludeTaggedFiles.cs
Normal file
@ -0,0 +1,58 @@
|
||||
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 IncludeTaggedFiles : ACompilationStep
|
||||
{
|
||||
private readonly List<AbsolutePath> _includeDirectly = new List<AbsolutePath>();
|
||||
private List<AbsolutePath> _tagFiles;
|
||||
private readonly string _tag;
|
||||
private readonly ACompiler _aCompiler;
|
||||
private readonly AbsolutePath _sourcePath;
|
||||
|
||||
public IncludeTaggedFiles(ACompiler compiler, string tag) : base(compiler)
|
||||
{
|
||||
_aCompiler = (ACompiler)compiler;
|
||||
_sourcePath = _aCompiler.SourcePath;
|
||||
_tag = tag;
|
||||
string rootDirectory = (string)_sourcePath;
|
||||
|
||||
_tagFiles = Directory.EnumerateFiles(rootDirectory, _tag, SearchOption.AllDirectories)
|
||||
.Select(str => (AbsolutePath)str)
|
||||
.ToList();
|
||||
|
||||
foreach (var tagFile in _tagFiles)
|
||||
{
|
||||
_includeDirectly.Add(tagFile);
|
||||
string[] taggedFiles = File.ReadAllLines((String)tagFile);
|
||||
foreach (var taggedFile in taggedFiles)
|
||||
{
|
||||
_includeDirectly.Add((AbsolutePath)(tagFile.ToString()
|
||||
.Replace(_tag,taggedFile)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
foreach (var folderpath in _includeDirectly)
|
||||
{
|
||||
if (!source.AbsolutePath.InFolder(folderpath)) continue;
|
||||
var result = source.EvolveTo<InlineFile>();
|
||||
result.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath);
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -437,6 +437,7 @@ namespace Wabbajack.Lib
|
||||
new IgnorePathContains(this, "SSEEdit Cache"),
|
||||
new IgnoreOtherProfiles(this),
|
||||
new IgnoreDisabledMods(this),
|
||||
new IgnoreTaggedFiles(this, Consts.WABBAJACK_IGNORE_FILES),
|
||||
new IgnoreTaggedFolders(this,Consts.WABBAJACK_IGNORE),
|
||||
new IncludeThisProfile(this),
|
||||
// Ignore the ModOrganizer.ini file it contains info created by MO2 on startup
|
||||
@ -481,6 +482,7 @@ namespace Wabbajack.Lib
|
||||
new zEditIntegration.IncludeZEditPatches(this),
|
||||
new IncludeTaggedMods(this, Consts.WABBAJACK_NOMATCH_INCLUDE),
|
||||
new IncludeTaggedFolders(this,Consts.WABBAJACK_NOMATCH_INCLUDE),
|
||||
new IncludeTaggedFiles(this,Consts.WABBAJACK_NOMATCH_INCLUDE_FILES),
|
||||
new IgnorePathContains(this,@"\Edit Scripts\Export\"),
|
||||
new IgnoreExtension(this, new Extension(".CACHE")),
|
||||
new DropAll(this)
|
||||
|
@ -280,11 +280,13 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
"IgnoreStartsWith" => new IgnoreStartsWith(this, step[1]),
|
||||
"IgnoreTaggedFolders" => new IgnoreTaggedFolders(this, Consts.WABBAJACK_IGNORE),
|
||||
"IgnoreTaggedFiles" => new IgnoreTaggedFiles(this, Consts.WABBAJACK_IGNORE_FILES),
|
||||
"IncludeTaggedFolders" => new IncludeTaggedFolders(this, Consts.WABBAJACK_INCLUDE),
|
||||
"IncludeConfigs" => new IncludeAllConfigs(this),
|
||||
"IncludeDirectMatches" => new DirectMatch(this),
|
||||
"IncludePatches" => new IncludePatches(this),
|
||||
"IncludeUnmatchedFilesInTaggedFolders" => new IncludeTaggedFolders(this, Consts.WABBAJACK_NOMATCH_INCLUDE),
|
||||
"IncludeUnmatchedTaggedFiles" => new IncludeTaggedFiles(this, Consts.WABBAJACK_NOMATCH_INCLUDE_FILES),
|
||||
_ => throw new ArgumentException($"No interpretation for step {step[0]}")
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user