mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix BSA copy errors
This commit is contained in:
parent
6449985185
commit
b475334d4b
@ -66,16 +66,16 @@ namespace Compression.BSA
|
||||
internal uint _totalFolderNameLength;
|
||||
internal uint _version;
|
||||
|
||||
public BSAReader(AbsolutePath filename) : this(filename.OpenRead())
|
||||
public BSAReader(AbsolutePath filename)
|
||||
{
|
||||
_fileName = filename;
|
||||
}
|
||||
|
||||
public BSAReader(Stream stream)
|
||||
{
|
||||
using var stream = filename.OpenRead();
|
||||
using var br = new BinaryReader(stream);
|
||||
_rdr = br;
|
||||
_stream = stream;
|
||||
_rdr = new BinaryReader(_stream);
|
||||
LoadHeaders();
|
||||
_rdr = null;
|
||||
_stream = null;
|
||||
}
|
||||
|
||||
public IEnumerable<IFile> Files
|
||||
@ -116,7 +116,6 @@ namespace Compression.BSA
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_stream.Close();
|
||||
}
|
||||
|
||||
private void LoadHeaders()
|
||||
|
@ -295,6 +295,41 @@ namespace Wabbajack.Test
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CanInstallFilesFromBSAAndBSA()
|
||||
{
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod();
|
||||
var file = utils.AddModFile(mod, @"baz.bin", 128);
|
||||
|
||||
await utils.Configure();
|
||||
|
||||
|
||||
using var tempFile = new TempFile();
|
||||
var bsaState = new BSAStateObject
|
||||
{
|
||||
Magic = "BSA\0", Version = 0x69, ArchiveFlags = 0x107, FileFlags = 0x0,
|
||||
};
|
||||
|
||||
await using (var bsa = bsaState.MakeBuilder(1024 * 1024))
|
||||
{
|
||||
await bsa.AddFile(new BSAFileStateObject
|
||||
{
|
||||
Path = (RelativePath)@"foo\bar\baz.bin", Index = 0, FlipCompression = false
|
||||
}, new MemoryStream(await file.ReadAllBytesAsync()));
|
||||
await bsa.Build(tempFile.Path);
|
||||
}
|
||||
tempFile.Path.CopyTo(file.Parent.Combine("bsa_data.bsa"));
|
||||
|
||||
var archive = utils.AddManualDownload(
|
||||
new Dictionary<string, byte[]> { { "/stuff/files.bsa", await tempFile.Path.ReadAllBytesAsync() } });
|
||||
|
||||
await CompileAndInstall(profile);
|
||||
utils.VerifyInstalledFile(mod, @"baz.bin");
|
||||
utils.VerifyInstalledFile(mod, @"bsa_data.bsa");
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CanRecreateBSAsFromFilesSourcedInOtherBSAs()
|
||||
{
|
||||
|
@ -40,6 +40,12 @@ namespace Wabbajack.VirtualFileSystem
|
||||
|
||||
public async Task MoveTo(AbsolutePath path)
|
||||
{
|
||||
if (FileExtractor.MightBeArchive(_path.Extension))
|
||||
{
|
||||
path.Parent.CreateDirectory();
|
||||
await _path.CopyToAsync(path);
|
||||
return;
|
||||
}
|
||||
await _path.MoveToAsync(path, true);
|
||||
_path = path;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user