(NsaOpener.OpenEntry): use StreamRegion instead of MemoryStream.

This commit is contained in:
morkt 2016-02-08 09:24:02 +04:00
parent c0afc205ee
commit c559dbccee

View File

@ -173,13 +173,9 @@ namespace GameRes.Formats.NScripter
var input = arc.File.CreateStream (entry.Offset, entry.Size); var input = arc.File.CreateStream (entry.Offset, entry.Size);
return UnpackEntry (input, entry as NsaEntry); return UnpackEntry (input, entry as NsaEntry);
} }
var data = new byte[entry.Size]; var encrypted = new EncryptedViewStream (arc.File, nsa_arc.Key);
using (var input = new EncryptedViewStream (arc.File, nsa_arc.Key)) var stream = new StreamRegion (encrypted, entry.Offset, entry.Size);
{ return UnpackEntry (stream, entry as NsaEntry);
input.Position = entry.Offset;
input.Read (data, 0, data.Length);
}
return UnpackEntry (new MemoryStream (data), entry as NsaEntry);
} }
protected Stream UnpackEntry (Stream input, NsaEntry nsa_entry) protected Stream UnpackEntry (Stream input, NsaEntry nsa_entry)