mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
switched the compiler/installer over to the new BSA libs
This commit is contained in:
parent
14aabe3d93
commit
5811380241
@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="libbsarch.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,372 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using static BSA.Tools.libbsarch;
|
||||
|
||||
namespace BSA.Tools
|
||||
{
|
||||
// Represents a BSA archive on disk (in READ mode)
|
||||
public class BSAFile : IDisposable
|
||||
{
|
||||
private static Mutex GlobalLock = new Mutex(false);
|
||||
protected unsafe libbsarch.bsa_archive_t* _archive;
|
||||
|
||||
public UInt32 Version
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_version_get(_archive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bsa_archive_type_t Type
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_archive_type_get(_archive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 FileCount
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_file_count_get(_archive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 ArchiveFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_archive_flags_get(_archive);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_archive_flags_set(_archive, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 FileFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_file_flags_get(_archive);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_file_flags_set(_archive, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Compress
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_compress_get(_archive);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_compress_set(_archive, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShareData
|
||||
{
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_share_data_get(_archive);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_share_data_set(_archive, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Save()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
check_err(libbsarch.bsa_save(_archive));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<ArchiveEntry> _entries = null;
|
||||
public IEnumerable<ArchiveEntry> Entries {
|
||||
get
|
||||
{
|
||||
if (_entries != null)
|
||||
return _entries;
|
||||
|
||||
return GetAndCacheEntries();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private IEnumerable<ArchiveEntry> GetAndCacheEntries()
|
||||
{
|
||||
var entries = new List<ArchiveEntry>();
|
||||
unsafe
|
||||
{
|
||||
foreach (var filename in GetFileNames())
|
||||
{
|
||||
entries.Add(new ArchiveEntry(this, _archive, filename));
|
||||
}
|
||||
}
|
||||
_entries = entries;
|
||||
return entries;
|
||||
}
|
||||
|
||||
public BSAFile()
|
||||
{
|
||||
GlobalLock.WaitOne();
|
||||
unsafe
|
||||
{
|
||||
_archive = libbsarch.bsa_create();
|
||||
}
|
||||
}
|
||||
|
||||
public void Create(string filename, bsa_archive_type_t type, EntryList entries)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
check_err(libbsarch.bsa_create_archive(_archive, filename, type, entries._list));
|
||||
}
|
||||
}
|
||||
|
||||
public BSAFile(string filename)
|
||||
{
|
||||
GlobalLock.WaitOne();
|
||||
unsafe
|
||||
{
|
||||
_archive = libbsarch.bsa_create();
|
||||
check_err(libbsarch.bsa_load_from_file(_archive, filename));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddFile(string filename, byte[] data)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
var ptr = Marshal.AllocHGlobal(data.Length);
|
||||
Marshal.Copy(data, 0, ptr, data.Length);
|
||||
libbsarch.bsa_add_file_from_memory(_archive, filename, (UInt32)data.Length, (byte*)ptr);
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
check_err(libbsarch.bsa_free(_archive));
|
||||
}
|
||||
GlobalLock.ReleaseMutex();
|
||||
}
|
||||
|
||||
public static void check_err(libbsarch.bsa_result_message_t bsa_result_message_t)
|
||||
{
|
||||
if (bsa_result_message_t.code != 0)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < 1024 * 2; i += 2)
|
||||
if (bsa_result_message_t.text[i] == 0) break;
|
||||
|
||||
var msg = new String((sbyte*)bsa_result_message_t.text, 0, i, Encoding.Unicode);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetFileNames()
|
||||
{
|
||||
List<string> filenames = new List<string>();
|
||||
unsafe
|
||||
{
|
||||
check_err(libbsarch.bsa_iterate_files(_archive, (archive, filename, file, folder, context) =>
|
||||
{
|
||||
lock (filenames)
|
||||
{
|
||||
filenames.Add(filename);
|
||||
}
|
||||
return false;
|
||||
}, null));
|
||||
}
|
||||
return filenames;
|
||||
}
|
||||
}
|
||||
|
||||
public class ArchiveEntry
|
||||
{
|
||||
private BSAFile _archive;
|
||||
private unsafe libbsarch.bsa_archive_t* _archivep;
|
||||
private string _filename;
|
||||
|
||||
public string Filename {
|
||||
get
|
||||
{
|
||||
return _filename;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe ArchiveEntry(BSAFile archive, libbsarch.bsa_archive_t* archivep, string filename)
|
||||
{
|
||||
_archive = archive;
|
||||
_archivep = archivep;
|
||||
_filename = filename;
|
||||
}
|
||||
|
||||
public FileData GetFileData()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
var result = libbsarch.bsa_extract_file_data_by_filename(_archivep, _filename);
|
||||
BSAFile.check_err(result.message);
|
||||
return new FileData(_archive, _archivep, result.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExtractTo(Stream stream)
|
||||
{
|
||||
using (var data = GetFileData())
|
||||
{
|
||||
data.WriteTo(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExtractTo(string filename)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_extract_file(_archivep, _filename, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FileData : IDisposable
|
||||
{
|
||||
private BSAFile archive;
|
||||
private unsafe libbsarch.bsa_archive_t* archivep;
|
||||
private libbsarch.bsa_result_buffer_t result;
|
||||
|
||||
public unsafe FileData(BSAFile archive, libbsarch.bsa_archive_t* archivep, libbsarch.bsa_result_buffer_t result)
|
||||
{
|
||||
this.archive = archive;
|
||||
this.archivep = archivep;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public void WriteTo(Stream stream)
|
||||
{
|
||||
var memory = ToByteArray();
|
||||
stream.Write(memory, 0, (int)result.size);
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
byte[] memory = new byte[result.size];
|
||||
Marshal.Copy((IntPtr)result.data, memory, 0, (int)result.size);
|
||||
return memory;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
BSAFile.check_err(libbsarch.bsa_file_data_free(archivep, result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EntryList : IDisposable
|
||||
{
|
||||
public unsafe bsa_entry_list_t* _list;
|
||||
|
||||
public EntryList()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
_list = libbsarch.bsa_entry_list_create();
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
return libbsarch.bsa_entry_list_count(_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string entry)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_entry_list_add(_list, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
libbsarch.bsa_entry_list_free(_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BSA.Tools
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static string ReadFourCC(this BinaryReader stream)
|
||||
{
|
||||
byte[] buf = new byte[4];
|
||||
stream.Read(buf, 0, 4);
|
||||
return new string(buf.Select(b => (char)b).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace BSA.Tools
|
||||
{
|
||||
public class libbsarch
|
||||
{
|
||||
public struct bsa_archive_t { };
|
||||
public struct bsa_file_record_t { };
|
||||
public struct bsa_folder_record_t { };
|
||||
|
||||
public unsafe delegate bool bsa_file_iteration_proc_t(bsa_archive_t archive, [MarshalAs(UnmanagedType.LPWStr)] string file_path, bsa_file_record_t *file_record, bsa_folder_record_t *folder_record, void* context);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_archive_t* bsa_create();
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
|
||||
public struct bsa_result_message_t
|
||||
{
|
||||
public byte code; // bsa_result_code_t
|
||||
|
||||
public unsafe fixed byte text[1024 * 2];
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
|
||||
public unsafe struct bsa_result_buffer_t
|
||||
{
|
||||
public UInt32 size;
|
||||
public IntPtr data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
|
||||
public unsafe struct bsa_result_message_buffer_t
|
||||
{
|
||||
public bsa_result_buffer_t buffer;
|
||||
public bsa_result_message_t message;
|
||||
}
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_free(bsa_archive_t* t);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_load_from_file(bsa_archive_t* archive, string file_path);
|
||||
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe UInt32 bsa_version_get(bsa_archive_t* archive);
|
||||
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe UInt32 bsa_file_count_get(bsa_archive_t* archive);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_iterate_files(bsa_archive_t *archive, bsa_file_iteration_proc_t file_iteration_proc, void* context);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_buffer_t bsa_extract_file_data_by_filename(bsa_archive_t* archive, string file_path);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_extract_file(bsa_archive_t* archive, string file_path, string save_as);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_file_data_free(bsa_archive_t* archive, bsa_result_buffer_t file_data_result);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_archive_type_t bsa_archive_type_get(bsa_archive_t* archive);
|
||||
|
||||
public enum bsa_archive_type_t : Int32
|
||||
{
|
||||
baNone, baTES3, baTES4, baFO3, baSSE, baFO4, baFO4dds
|
||||
}
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
|
||||
public static extern unsafe bsa_result_message_t bsa_add_file_from_memory(bsa_archive_t* archive, string file_path, UInt32 size, byte* data);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_save(bsa_archive_t* archive);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_create_archive(bsa_archive_t* archive, string file_path, bsa_archive_type_t archive_type, bsa_entry_list_t* entry_list);
|
||||
|
||||
|
||||
// Entry Lists
|
||||
|
||||
public struct bsa_entry_list_t { }
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_entry_list_t* bsa_entry_list_create();
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_entry_list_free(bsa_entry_list_t* entry_list);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe UInt32 bsa_entry_list_count(bsa_entry_list_t* entry_list);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bsa_result_message_t bsa_entry_list_add(bsa_entry_list_t* entry_list, string entry_string);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe UInt32 bsa_entry_list_get(bsa_entry_list_t* entry_list, UInt32 index, UInt32 string_buffer_size, string string_buffer);
|
||||
|
||||
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe UInt32 bsa_archive_flags_get(bsa_archive_t* archive);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe void bsa_archive_flags_set(bsa_archive_t* archive, UInt32 flags);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe UInt32 bsa_file_flags_get(bsa_archive_t* archive);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe void bsa_file_flags_set(bsa_archive_t* archive, UInt32 flags);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bool bsa_compress_get(bsa_archive_t* archive);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe void bsa_compress_set(bsa_archive_t* archive, bool flags);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe bool bsa_share_data_get(bsa_archive_t* archive);
|
||||
|
||||
[DllImport("libbsarch.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern unsafe void bsa_share_data_set(bsa_archive_t* archive, bool flags);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Binary file not shown.
@ -13,7 +13,7 @@ namespace Compression.BSA.Test
|
||||
const string TempDir = "c:\\tmp\\out";
|
||||
static void Main(string[] args)
|
||||
{
|
||||
foreach (var bsa in Directory.EnumerateFiles(TestDir, "*.bsa", SearchOption.AllDirectories).Skip(16))
|
||||
foreach (var bsa in Directory.EnumerateFiles(TestDir, "*.bsa", SearchOption.AllDirectories))
|
||||
{
|
||||
Console.WriteLine($"From {bsa}");
|
||||
Console.WriteLine("Cleaning Output Dir");
|
||||
|
@ -11,6 +11,7 @@ namespace Compression.BSA
|
||||
{
|
||||
public class BSABuilder : IDisposable
|
||||
{
|
||||
internal LZ4Level _compressionLevel;
|
||||
internal byte[] _fileId;
|
||||
internal uint _version;
|
||||
internal uint _offset;
|
||||
@ -26,6 +27,7 @@ namespace Compression.BSA
|
||||
|
||||
public BSABuilder()
|
||||
{
|
||||
_compressionLevel = LZ4Level.L10_OPT;
|
||||
_fileId = Encoding.ASCII.GetBytes("BSA\0");
|
||||
_offset = 0x24;
|
||||
}
|
||||
@ -326,7 +328,7 @@ namespace Compression.BSA
|
||||
if (_bsa.HeaderType == VersionType.SSE)
|
||||
{
|
||||
var r = new MemoryStream();
|
||||
using (var w = LZ4Stream.Encode(r))
|
||||
using (var w = LZ4Stream.Encode(r, new LZ4EncoderSettings() { CompressionLevel = _bsa._compressionLevel }))
|
||||
(new MemoryStream(_rawData)).CopyTo(w);
|
||||
|
||||
_rawData = r.ToArray();
|
||||
|
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace Compression.BSA
|
||||
{
|
||||
public static class Utils
|
||||
internal static class Utils
|
||||
{
|
||||
private static Encoding Windows1251 = Encoding.GetEncoding(1251);
|
||||
public static string ReadStringLen(this BinaryReader rdr)
|
||||
|
@ -8,6 +8,7 @@ rights of the game publisher and the mod authors.
|
||||
### Socal Links
|
||||
[Discord](https://discord.gg/zgbrkmA)
|
||||
|
||||
|
||||
### How it works
|
||||
At a technical level the process is as follows.
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace Wabbajack.Common
|
||||
public string TempID;
|
||||
public string IsCompressed;
|
||||
public uint Version;
|
||||
public Int32 Type;
|
||||
public uint Type;
|
||||
public bool ShareData;
|
||||
|
||||
public uint FileFlags { get; set; }
|
||||
|
@ -66,10 +66,6 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BSA.Tools\BSA.Tools.csproj">
|
||||
<Project>{b6389807-ea59-4633-b42b-a85f52fec135}</Project>
|
||||
<Name>BSA.Tools</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SevenZipExtractor\SevenZipExtractor.csproj">
|
||||
<Project>{8aa97f58-5044-4bba-b8d9-a74b6947a660}</Project>
|
||||
<Name>SevenZipExtractor</Name>
|
||||
|
@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.29102.190
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.Common", "Wabbajack.Common\Wabbajack.Common.csproj", "{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BSA.Tools", "BSA.Tools\BSA.Tools.csproj", "{B6389807-EA59-4633-B42B-A85F52FEC135}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SevenZipExtractor", "SevenZipExtractor\SevenZipExtractor.csproj", "{8AA97F58-5044-4BBA-B8D9-A74B6947A660}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack", "Wabbajack\Wabbajack.csproj", "{33602679-8484-40C7-A10C-774DFF5D8314}"
|
||||
@ -15,6 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compression.BSA", "Compress
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compression.BSA.Test", "Compression.BSA.Test\Compression.BSA.Test.csproj", "{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4EDEF6CC-2F5C-439B-BEAF-9D03895099F1}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
LICENSE.txt = LICENSE.txt
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -25,10 +29,6 @@ Global
|
||||
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B6389807-EA59-4633-B42B-A85F52FEC135}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B6389807-EA59-4633-B42B-A85F52FEC135}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B6389807-EA59-4633-B42B-A85F52FEC135}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B6389807-EA59-4633-B42B-A85F52FEC135}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8AA97F58-5044-4BBA-B8D9-A74B6947A660}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8AA97F58-5044-4BBA-B8D9-A74B6947A660}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8AA97F58-5044-4BBA-B8D9-A74B6947A660}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -1,4 +1,4 @@
|
||||
using BSA.Tools;
|
||||
using Compression.BSA;
|
||||
using Newtonsoft.Json;
|
||||
using SevenZipExtractor;
|
||||
using SharpCompress.Archives;
|
||||
@ -295,13 +295,10 @@ namespace Wabbajack
|
||||
var bsa_id = to.Split('\\')[1];
|
||||
var bsa = InstallDirectives.OfType<CreateBSA>().First(b => b.TempID == bsa_id);
|
||||
|
||||
using (var a = new BSAFile(Path.Combine(MO2Folder, bsa.To)))
|
||||
using (var a = new BSAReader(Path.Combine(MO2Folder, bsa.To)))
|
||||
{
|
||||
var file = a.Entries.First(e => e.Filename == Path.Combine(to.Split('\\').Skip(2).ToArray()));
|
||||
using (var data = file.GetFileData())
|
||||
{
|
||||
return data.ToByteArray();
|
||||
}
|
||||
var file = a.Files.First(e => e.Path == Path.Combine(to.Split('\\').Skip(2).ToArray()));
|
||||
return file.GetData();
|
||||
}
|
||||
|
||||
}
|
||||
@ -498,18 +495,15 @@ namespace Wabbajack
|
||||
};
|
||||
|
||||
CreateBSA directive;
|
||||
using (var bsa = new BSAFile(source.AbsolutePath))
|
||||
using (var bsa = new BSAReader(source.AbsolutePath))
|
||||
{
|
||||
directive = new CreateBSA()
|
||||
{
|
||||
To = source.Path,
|
||||
TempID = id,
|
||||
Version = bsa.Version,
|
||||
Type = (int)bsa.Type,
|
||||
FileFlags = bsa.FileFlags,
|
||||
ArchiveFlags = bsa.ArchiveFlags,
|
||||
Compress = bsa.Compress,
|
||||
ShareData = bsa.ShareData
|
||||
Type = (uint)bsa.HeaderType,
|
||||
FileFlags = (uint)bsa.FileFlags,
|
||||
ArchiveFlags = (uint)bsa.ArchiveFlags,
|
||||
};
|
||||
};
|
||||
|
||||
@ -527,16 +521,14 @@ namespace Wabbajack
|
||||
{
|
||||
Status($"Hashing BSA: {absolutePath}");
|
||||
var results = new List<(string, string)>();
|
||||
using (var a = new BSAFile(absolutePath))
|
||||
using (var a = new BSAReader(absolutePath))
|
||||
{
|
||||
foreach (var entry in a.Entries)
|
||||
foreach (var entry in a.Files)
|
||||
{
|
||||
Status($"Hashing BSA: {absolutePath} - {entry.Filename}");
|
||||
Status($"Hashing BSA: {absolutePath} - {entry.Path}");
|
||||
|
||||
using (var data = entry.GetFileData())
|
||||
{
|
||||
results.Add((entry.Filename, data.ToByteArray().SHA256()));
|
||||
};
|
||||
var data = entry.GetData();
|
||||
results.Add((entry.Path, data.SHA256()));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using BSA.Tools;
|
||||
using Compression.BSA;
|
||||
using SevenZipExtractor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -9,7 +9,6 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using static BSA.Tools.libbsarch;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -91,38 +90,35 @@ namespace Wabbajack
|
||||
private void BuildBSAs()
|
||||
{
|
||||
var bsas = ModList.Directives.OfType<CreateBSA>().ToList();
|
||||
Info("Building {0} bsa files");
|
||||
Info($"Building {bsas.Count} bsa files");
|
||||
|
||||
bsas.Do(bsa =>
|
||||
{
|
||||
Status($"Building {bsa.To}");
|
||||
var source_dir = Path.Combine(Outputfolder, Consts.BSACreationDir, bsa.TempID);
|
||||
using (var entries = new EntryList())
|
||||
{
|
||||
var source_files = Directory.EnumerateFiles(source_dir, "*", SearchOption.AllDirectories)
|
||||
.Select(e => e.Substring(source_dir.Length + 1))
|
||||
.ToList();
|
||||
|
||||
source_files.Do(name => entries.Add(name));
|
||||
|
||||
using (var a = new BSAFile())
|
||||
using (var a = new BSABuilder())
|
||||
{
|
||||
|
||||
a.Create(Path.Combine(Outputfolder, bsa.To), (bsa_archive_type_t)bsa.Type, entries);
|
||||
a.FileFlags = bsa.FileFlags;
|
||||
a.ArchiveFlags = bsa.ArchiveFlags;
|
||||
a.ShareData = bsa.ShareData;
|
||||
//a.Create(Path.Combine(Outputfolder, bsa.To), (bsa_archive_type_t)bsa.Type, entries);
|
||||
a.HeaderType = (VersionType)bsa.Type;
|
||||
a.FileFlags = (FileFlags)bsa.FileFlags;
|
||||
a.ArchiveFlags = (ArchiveFlags)bsa.ArchiveFlags;
|
||||
|
||||
|
||||
source_files.Do(e =>
|
||||
source_files.PMap(f =>
|
||||
{
|
||||
a.AddFile(e, File.ReadAllBytes(Path.Combine(source_dir, e)));
|
||||
Status($"Adding {f} to BSA");
|
||||
using (var fs = File.OpenRead(Path.Combine(source_dir, f)))
|
||||
a.AddFile(f, fs);
|
||||
});
|
||||
|
||||
a.Save();
|
||||
Info($"Writing {bsa.To}");
|
||||
a.Build(Path.Combine(Outputfolder, bsa.To));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -117,9 +117,9 @@
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BSA.Tools\BSA.Tools.csproj">
|
||||
<Project>{b6389807-ea59-4633-b42b-a85f52fec135}</Project>
|
||||
<Name>BSA.Tools</Name>
|
||||
<ProjectReference Include="..\Compression.BSA\Compression.BSA.csproj">
|
||||
<Project>{ff5d892f-8ff4-44fc-8f7f-cd58f307ad1b}</Project>
|
||||
<Name>Compression.BSA</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SevenZipExtractor\SevenZipExtractor.csproj">
|
||||
<Project>{8aa97f58-5044-4bba-b8d9-a74b6947a660}</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user