[Blb3] Fixed some blocks parsing, some refactoring
This commit is contained in:
@@ -79,61 +79,16 @@ namespace AssetStudio
|
||||
}
|
||||
else
|
||||
{
|
||||
using var reader = new FileReader(path, this, true);
|
||||
|
||||
var readSignature = reader.FileType;
|
||||
var signature = "";
|
||||
|
||||
if (readSignature == FileType.BundleFile ||
|
||||
readSignature == FileType.MhyFile ||
|
||||
readSignature == FileType.Blb3File)
|
||||
while (Remaining > 0)
|
||||
{
|
||||
switch (reader.FileType)
|
||||
Offset = AbsolutePosition;
|
||||
yield return AbsolutePosition;
|
||||
if (Offset == AbsolutePosition)
|
||||
{
|
||||
case FileType.BundleFile:
|
||||
signature = "UnityFS\x00";
|
||||
break;
|
||||
case FileType.MhyFile:
|
||||
signature = "mhy0";
|
||||
break;
|
||||
case FileType.Blb3File:
|
||||
signature = "Blb\x03";
|
||||
break;
|
||||
}
|
||||
|
||||
Logger.Verbose($"Parsed signature: {signature}");
|
||||
|
||||
var signatureBytes = Encoding.UTF8.GetBytes(signature);
|
||||
var buffer = ArrayPool<byte>.Shared.Rent((int)reader.Length);
|
||||
while (Remaining > 0)
|
||||
{
|
||||
var index = 0;
|
||||
var absOffset = AbsolutePosition;
|
||||
var read = Read(buffer);
|
||||
while (index < read)
|
||||
{
|
||||
index = buffer.AsSpan(0, read).Search(signatureBytes, index);
|
||||
if (index == -1) break;
|
||||
var offset = absOffset + index;
|
||||
Offset = offset;
|
||||
yield return offset;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
ArrayPool<byte>.Shared.Return(buffer);
|
||||
} else
|
||||
{
|
||||
while (Remaining > 0)
|
||||
{
|
||||
Offset = AbsolutePosition;
|
||||
yield return AbsolutePosition;
|
||||
if (Offset == AbsolutePosition)
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user