Ejemplo n.º 1
0
        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 _));
        }
Ejemplo n.º 2
0
        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");
            }
        }