예제 #1
0
        public IArchive Open(Stream stream, IFileFormat archiveFormat, IArchiveOptions archiveOptions)
        {
            if (archiveFormat is null)
            {
                stream = FileFormatFactory.Default.FromStream(stream, out archiveFormat);
            }

            if (archiveOptions is null)
            {
                archiveOptions = ArchiveOptions.Default;
            }

            if (!this.IsSupportedFileFormat(archiveFormat))
            {
                throw new FileFormatException(IO.Properties.ExceptionMessages.UnsupportedFileFormat);
            }

            if (archiveFormat.Equals(ArchiveFormat.Zip))
            {
                return(new SharpCompressSevenZipArchive(stream, archiveOptions));
            }
            else if (archiveFormat.Equals(ArchiveFormat.SevenZip))
            {
                return(new SharpCompressSevenZipArchive(stream, archiveOptions));
            }
            else
            {
                throw new FileFormatException(IO.Properties.ExceptionMessages.UnsupportedFileFormat);
            }
        }