public void ExtractSegment(string path, INsoSegment segment) { if (!(segment is NsoSegment)) { throw new NsoException("Invalid segment"); } using (MemoryStream ms = new MemoryStream(((NsoSegment)segment).RawData)) using (var fs = File.Create(path)) ms.CopyTo(fs); }
public void ResizeSegment(INsoSegment segment, uint newSize) { if (!(segment is NsoSegment)) { throw new NsoException("Cannot resize unknown segment"); } ((NsoSegment)segment).DecompressedSize = newSize; byte[] buff = new byte[newSize]; Buffer.BlockCopy(((NsoSegment)segment).RawData, 0, buff, 0, (int)Math.Min(((NsoSegment)segment).RawData.Length, newSize)); ((NsoSegment)segment).RawData = buff; }