Extracts a XZ-compressed TAR archive.
Inheritance: TarExtractor
Exemple #1
0
        public static ArchiveExtractor Create([NotNull] Stream stream, [NotNull] string target, [CanBeNull] string mimeType)
        {
            #region Sanity checks
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (string.IsNullOrEmpty(target))
            {
                throw new ArgumentNullException(nameof(target));
            }
            #endregion

            ArchiveExtractor extractor;
            switch (mimeType)
            {
            case Archive.MimeTypeZip:
                extractor = new ZipExtractor(stream, target);
                break;

            case Archive.MimeTypeTar:
                extractor = new TarExtractor(stream, target);
                break;

            case Archive.MimeTypeTarGzip:
                extractor = new TarGzExtractor(stream, target);
                break;

            case Archive.MimeTypeTarBzip:
                extractor = new TarBz2Extractor(stream, target);
                break;

            case Archive.MimeTypeTarLzma:
                extractor = new TarLzmaExtractor(stream, target);
                break;

            case Archive.MimeTypeTarXz:
                extractor = new TarXzExtractor(stream, target);
                break;

            case Archive.MimeTypeRubyGem:
                extractor = new RubyGemExtractor(stream, target);
                break;

            case Archive.MimeType7Z:
                extractor = new SevenZipExtractor(stream, target);
                break;

            case Archive.MimeTypeCab:
                extractor = new CabExtractor(stream, target);
                break;

            case Archive.MimeTypeMsi:
                throw new NotSupportedException("MSIs can only be accessed as local files, not as streams!");

            default:
                throw new NotSupportedException(string.Format(Resources.UnsupportedArchiveMimeType, mimeType));
            }

            return(extractor);
        }
        public static ArchiveExtractor Create([NotNull] Stream stream, [NotNull] string target, [CanBeNull] string mimeType)
        {
            #region Sanity checks
            if (stream == null) throw new ArgumentNullException(nameof(stream));
            if (string.IsNullOrEmpty(target)) throw new ArgumentNullException(nameof(target));
            #endregion

            ArchiveExtractor extractor;
            switch (mimeType)
            {
                case Archive.MimeTypeZip:
                    extractor = new ZipExtractor(stream, target);
                    break;
                case Archive.MimeTypeTar:
                    extractor = new TarExtractor(stream, target);
                    break;
                case Archive.MimeTypeTarGzip:
                    extractor = new TarGzExtractor(stream, target);
                    break;
                case Archive.MimeTypeTarBzip:
                    extractor = new TarBz2Extractor(stream, target);
                    break;
                case Archive.MimeTypeTarLzma:
                    extractor = new TarLzmaExtractor(stream, target);
                    break;
                case Archive.MimeTypeTarXz:
                    extractor = new TarXzExtractor(stream, target);
                    break;
                case Archive.MimeTypeRubyGem:
                    extractor = new RubyGemExtractor(stream, target);
                    break;
                case Archive.MimeType7Z:
                    extractor = new SevenZipExtractor(stream, target);
                    break;
                case Archive.MimeTypeCab:
                    extractor = new CabExtractor(stream, target);
                    break;
                case Archive.MimeTypeMsi:
                    throw new NotSupportedException("MSIs can only be accessed as local files, not as streams!");
                default:
                    throw new NotSupportedException(string.Format(Resources.UnsupportedArchiveMimeType, mimeType));
            }

            return extractor;
        }