mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
add brotli compression support
This commit is contained in:
parent
8891414f60
commit
62206f8977
@ -394,7 +394,13 @@ namespace Unity_Studio
|
||||
{
|
||||
return FileType.WebFile;
|
||||
}
|
||||
|
||||
reader.Position = 0x20;
|
||||
magic = reader.ReadBytes(6);
|
||||
reader.Position = 0;
|
||||
if (WebFile.brotliMagic.SequenceEqual(magic))
|
||||
{
|
||||
return FileType.WebFile;
|
||||
}
|
||||
return FileType.AssetsFile;
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@ using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BrotliSharpLib;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class WebFile
|
||||
{
|
||||
public static byte[] gzipMagic = { 0x1f, 0x8b };
|
||||
public static byte[] brotliMagic = { 0x62, 0x72, 0x6F, 0x74, 0x6C, 0x69 };
|
||||
public List<MemoryFile> fileList = new List<MemoryFile>();
|
||||
|
||||
|
||||
@ -28,9 +30,9 @@ namespace Unity_Studio
|
||||
if (gzipMagic.SequenceEqual(magic))
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
using (var gstream = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
|
||||
using (var gs = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
|
||||
{
|
||||
gstream.CopyTo(stream);
|
||||
gs.CopyTo(stream);
|
||||
}
|
||||
stream.Position = 0;
|
||||
using (reader = new EndianBinaryReader(stream, EndianType.LittleEndian))
|
||||
@ -40,8 +42,24 @@ namespace Unity_Studio
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.endian = EndianType.LittleEndian;
|
||||
ReadUnityWebData(reader);
|
||||
reader.Position = 0x20;
|
||||
magic = reader.ReadBytes(6);
|
||||
reader.Position = 0;
|
||||
if (brotliMagic.SequenceEqual(magic))
|
||||
{
|
||||
var buff = reader.ReadBytes((int)reader.BaseStream.Length);
|
||||
var uncompressedData = Brotli.DecompressBuffer(buff, 0, buff.Length);
|
||||
var stream = new MemoryStream(uncompressedData);
|
||||
using (reader = new EndianBinaryReader(stream, EndianType.LittleEndian))
|
||||
{
|
||||
ReadUnityWebData(reader);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.endian = EndianType.LittleEndian;
|
||||
ReadUnityWebData(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,11 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BrotliSharpLib, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\BrotliSharpLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\OpenTK.dll</HintPath>
|
||||
@ -187,7 +192,7 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Unity Studio Classes\AssetsFile.cs" />
|
||||
<Compile Include="Unity Studio Classes\WebFile.cs" />
|
||||
<Compile Include="Unity Studio Classes\WebFile.cs" />
|
||||
<Compile Include="UnityStudioForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -55,6 +55,11 @@
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BrotliSharpLib, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\BrotliSharpLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>library\OpenTK.dll</HintPath>
|
||||
|
BIN
Unity Studio/library/BrotliSharpLib.dll
Normal file
BIN
Unity Studio/library/BrotliSharpLib.dll
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user