/// <summary> /// Initializes a new instance of the SdiFile class. /// </summary> /// <param name="stream">The stream formatted as an SDI file.</param> /// <param name="ownership">Whether to pass ownership of <c>stream</c> to the new instance.</param> public SdiFile(Stream stream, Ownership ownership) { _stream = stream; _ownership = ownership; byte[] page = Utilities.ReadFully(_stream, 512); _header = new FileHeader(); _header.ReadFrom(page, 0); _stream.Position = _header.PageAlignment * 512; byte[] toc = Utilities.ReadFully(_stream, (int)(_header.PageAlignment * 512)); _sections = new List<SectionRecord>(); int pos = 0; while (Utilities.ToUInt64LittleEndian(toc, pos) != 0) { SectionRecord record = new SectionRecord(); record.ReadFrom(toc, pos); _sections.Add(record); pos += SectionRecord.RecordSize; } }