use IBinaryStream interface instead of BinaryReader where appropriate.

This commit is contained in:
morkt
2016-10-16 18:29:54 +04:00
parent 3a1bae1a19
commit df01ce1893
23 changed files with 195 additions and 299 deletions

View File

@@ -115,17 +115,17 @@ namespace GameRes.Formats.SPack
}
}
internal class PackedReader : IDisposable
internal sealed class PackedReader : IDisposable
{
BinaryReader m_input;
IBinaryStream m_input;
uint m_packed_size;
byte[] m_output;
public byte[] Data { get { return m_output; } }
public PackedReader (SPackEntry entry, Stream input)
public PackedReader (SPackEntry entry, IBinaryStream input)
{
m_input = new BinaryReader (input);
m_input = input;
m_packed_size = entry.Size;
m_output = new byte[entry.UnpackedSize];
}
@@ -149,7 +149,7 @@ namespace GameRes.Formats.SPack
{
int copy_count, offset;
offset = m_input.ReadByte();
offset = m_input.ReadUInt8();
src++;
copy_count = offset >> 4;
offset &= 0x0f;
@@ -160,7 +160,7 @@ namespace GameRes.Formats.SPack
}
else if (14 == copy_count)
{
copy_count = m_input.ReadByte();
copy_count = m_input.ReadUInt8();
src++;
}
else
@@ -170,7 +170,7 @@ namespace GameRes.Formats.SPack
offset++;
else
{
offset = ((offset - 10) << 8) | m_input.ReadByte();
offset = ((offset - 10) << 8) | m_input.ReadUInt8();
src++;
}
@@ -181,7 +181,7 @@ namespace GameRes.Formats.SPack
}
else
{
m_output[dst++] = m_input.ReadByte();
m_output[dst++] = m_input.ReadUInt8();
src++;
}
mask >>= 1;
@@ -193,21 +193,13 @@ namespace GameRes.Formats.SPack
bool disposed = false;
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (!disposed)
{
if (disposing)
{
m_input.Dispose();
}
m_input.Dispose();
disposed = true;
}
GC.SuppressFinalize (this);
}
#endregion
}