mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #1341 from LostDragonist/omod_fix
Fix compiling with OMODs
This commit is contained in:
commit
278bfec349
@ -17,7 +17,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
{
|
{
|
||||||
public static class FileExtractor2
|
public static class FileExtractor2
|
||||||
{
|
{
|
||||||
public static readonly SignatureChecker ArchiveSigs = new(Definitions.FileType.TES3,
|
public static readonly SignatureChecker ArchiveSigs = new(Definitions.FileType.TES3,
|
||||||
Definitions.FileType.BSA,
|
Definitions.FileType.BSA,
|
||||||
Definitions.FileType.BA2,
|
Definitions.FileType.BA2,
|
||||||
Definitions.FileType.ZIP,
|
Definitions.FileType.ZIP,
|
||||||
@ -28,7 +28,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
|
|
||||||
private static Extension OMODExtension = new(".omod");
|
private static Extension OMODExtension = new(".omod");
|
||||||
private static Extension FOMODExtension = new(".fomod");
|
private static Extension FOMODExtension = new(".fomod");
|
||||||
|
|
||||||
private static Extension BSAExtension = new(".bsa");
|
private static Extension BSAExtension = new(".bsa");
|
||||||
|
|
||||||
public static readonly HashSet<Extension> ExtractableExtensions = new HashSet<Extension>
|
public static readonly HashSet<Extension> ExtractableExtensions = new HashSet<Extension>
|
||||||
@ -42,8 +42,8 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
OMODExtension,
|
OMODExtension,
|
||||||
FOMODExtension
|
FOMODExtension
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, will allow 7z to use multiple threads and cache more data in memory, potentially
|
/// When true, will allow 7z to use multiple threads and cache more data in memory, potentially
|
||||||
/// using many GB of RAM during extraction but vastly reducing extraction times in the process.
|
/// using many GB of RAM during extraction but vastly reducing extraction times in the process.
|
||||||
@ -58,7 +58,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
{
|
{
|
||||||
if (tempFolder == null)
|
if (tempFolder == null)
|
||||||
tempFolder = TempFolder.BaseFolder;
|
tempFolder = TempFolder.BaseFolder;
|
||||||
|
|
||||||
if (sFn is NativeFileStreamFactory)
|
if (sFn is NativeFileStreamFactory)
|
||||||
{
|
{
|
||||||
Utils.Log($"Extracting {sFn.Name}");
|
Utils.Log($"Extracting {sFn.Name}");
|
||||||
@ -96,7 +96,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Definitions.FileType.TES3:
|
case Definitions.FileType.TES3:
|
||||||
if (sFn.Name.FileName.Extension == BSAExtension)
|
if (sFn.Name.FileName.Extension == BSAExtension)
|
||||||
results = await GatheringExtractWithBSA(sFn, (Definitions.FileType)sig, shouldExtract, mapfn);
|
results = await GatheringExtractWithBSA(sFn, (Definitions.FileType)sig, shouldExtract, mapfn);
|
||||||
else
|
else
|
||||||
throw new Exception($"Invalid file format {sFn.Name}");
|
throw new Exception($"Invalid file format {sFn.Name}");
|
||||||
@ -112,7 +112,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<Dictionary<RelativePath,T>> GatheringExtractWithOMOD<T>(Stream archive, Predicate<RelativePath> shouldExtract, Func<RelativePath,IExtractedFile,ValueTask<T>> mapfn)
|
private static async Task<Dictionary<RelativePath,T>> GatheringExtractWithOMOD<T>(Stream archive, Predicate<RelativePath> shouldExtract, Func<RelativePath,IExtractedFile,ValueTask<T>> mapfn)
|
||||||
{
|
{
|
||||||
var tmpFile = new TempFile();
|
var tmpFile = new TempFile();
|
||||||
@ -122,24 +122,24 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
|
|
||||||
Framework.Settings.TempPath = (string)dest.Dir;
|
Framework.Settings.TempPath = (string)dest.Dir;
|
||||||
Framework.Settings.CodeProgress = new OMODProgress();
|
Framework.Settings.CodeProgress = new OMODProgress();
|
||||||
|
|
||||||
var omod = new OMOD((string)tmpFile.Path);
|
var omod = new OMOD((string)tmpFile.Path);
|
||||||
omod.GetDataFiles();
|
omod.GetDataFiles();
|
||||||
omod.GetPlugins();
|
omod.GetPlugins();
|
||||||
|
|
||||||
var results = new Dictionary<RelativePath, T>();
|
var results = new Dictionary<RelativePath, T>();
|
||||||
foreach (var file in dest.Dir.EnumerateFiles())
|
foreach (var file in dest.Dir.EnumerateFiles())
|
||||||
{
|
{
|
||||||
var path = file.RelativeTo(dest.Dir);
|
var path = file.RelativeTo(dest.Dir);
|
||||||
if (!shouldExtract(path)) continue;
|
if (!shouldExtract(path)) continue;
|
||||||
|
|
||||||
var result = await mapfn(path, new ExtractedNativeFile(file, path));
|
var result = await mapfn(path, new ExtractedNativeFile(file));
|
||||||
results.Add(path, result);
|
results.Add(path, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OMODProgress : ICodeProgress
|
private class OMODProgress : ICodeProgress
|
||||||
{
|
{
|
||||||
private long _total;
|
private long _total;
|
||||||
@ -183,7 +183,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
TempFile tmpFile = null;
|
TempFile tmpFile = null;
|
||||||
var dest = tempPath.Combine(Guid.NewGuid().ToString());
|
var dest = tempPath.Combine(Guid.NewGuid().ToString());
|
||||||
dest.CreateDirectory();
|
dest.CreateDirectory();
|
||||||
|
|
||||||
TempFile spoolFile = null;
|
TempFile spoolFile = null;
|
||||||
AbsolutePath source;
|
AbsolutePath source;
|
||||||
|
|
||||||
@ -265,14 +265,14 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
await f.DeleteAsync();
|
await f.DeleteAsync();
|
||||||
return (path, result);
|
return (path, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
return results.Where(d => d.Item1 != default)
|
return results.Where(d => d.Item1 != default)
|
||||||
.ToDictionary(d => d.Item1, d => d.Item2);
|
.ToDictionary(d => d.Item1, d => d.Item2);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
await dest.DeleteDirectory();
|
await dest.DeleteDirectory();
|
||||||
|
|
||||||
if (tmpFile != null)
|
if (tmpFile != null)
|
||||||
{
|
{
|
||||||
await tmpFile.DisposeAsync();
|
await tmpFile.DisposeAsync();
|
||||||
|
Loading…
Reference in New Issue
Block a user