mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix some nasty bugs with name blob sizes and hashes in Compression.BSA
This commit is contained in:
parent
167b81d586
commit
3cf766c941
19
Compression.BSA.Test/UnitTests.cs
Normal file
19
Compression.BSA.Test/UnitTests.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Wabbajack.Common;
|
||||
using Xunit;
|
||||
|
||||
namespace Compression.BSA.Test
|
||||
{
|
||||
public class UnitTests
|
||||
{
|
||||
[Fact]
|
||||
public void HashesRespectFolderExtensions()
|
||||
{
|
||||
Assert.Equal((ulong)0x085B31F63008E2B6, BSAUtils.GetBSAHash("005930b6.dds"));
|
||||
|
||||
|
||||
// Old code has a bug where we were stripping the `.esp` from the folder which we shoudn't do when creating folder paths
|
||||
Assert.Equal((ulong)0x38C7A858743A7370, BSAUtils.GetFolderBSAHash((RelativePath)@"textures\actors\character\facegendata\facetint\darkend.esp"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -152,7 +152,7 @@ namespace Compression.BSA
|
||||
Name = folderName;
|
||||
_bsa = bsa;
|
||||
// Folders don't have extensions, so let's make sure we cut it out
|
||||
_hash = Name.GetBSAHash();
|
||||
_hash = Name.GetFolderBSAHash();
|
||||
_fileCount = (uint) files.Count();
|
||||
_nameBytes = folderName.ToBZString(_bsa.HeaderType);
|
||||
_recordSize = sizeof(ulong) + sizeof(uint) + sizeof(uint);
|
||||
|
@ -8,11 +8,11 @@ using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
|
||||
namespace Compression.BSA
|
||||
{
|
||||
internal static class Utils
|
||||
public static class BSAUtils
|
||||
{
|
||||
private static readonly Encoding Windows1252;
|
||||
|
||||
static Utils()
|
||||
static BSAUtils()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
Windows1252 = Encoding.GetEncoding(1252);
|
||||
@ -129,6 +129,11 @@ namespace Compression.BSA
|
||||
{
|
||||
return ((string)name).GetBSAHash();
|
||||
}
|
||||
|
||||
public static ulong GetFolderBSAHash(this RelativePath name)
|
||||
{
|
||||
return GetBSAHash((string)name, "");
|
||||
}
|
||||
|
||||
public static ulong GetBSAHash(this string name, string ext)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user