mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-14 11:18:47 -05:00
Allocation-safe asset reading
Try to not pre-allocate memory during asset reading
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
@@ -16,6 +17,8 @@ namespace AssetStudio
|
||||
|
||||
public UnityVersion version => assetsFile.version;
|
||||
|
||||
public long Remaining => byteStart + byteSize - Position;
|
||||
|
||||
public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.Endian)
|
||||
{
|
||||
this.assetsFile = assetsFile;
|
||||
@@ -36,6 +39,12 @@ namespace AssetStudio
|
||||
m_Version = assetsFile.header.m_Version;
|
||||
}
|
||||
|
||||
public void ThrowIfTooLarge(float val)
|
||||
{
|
||||
if (val < 0 || val > Remaining)
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Position = byteStart;
|
||||
|
||||
Reference in New Issue
Block a user