public static bool IsDmgFile(Stream stream) { long headerPos = stream.Length - DmgHeader.HeaderSize; if (headerPos < 0) { return(false); } stream.Position = headerPos; return(DmgHeader.TryRead(stream, out _)); }
public DmgVolume(DmgArchive archive, Stream stream, string fileName, Readers.ReaderOptions readerOptions) : base(stream, readerOptions) { _archive = archive; _fileName = fileName; long pos = stream.Length - DmgHeader.HeaderSize; if (pos < 0) { throw new InvalidFormatException("Invalid DMG volume"); } stream.Position = pos; if (DmgHeader.TryRead(stream, out var header)) { Header = header !; } else { throw new InvalidFormatException("Invalid DMG volume"); } }