Extracts a BZip2-compressed TAR archive.
상속: TarExtractor
예제 #1
0
        public static Extractor FromStream([NotNull] Stream stream, [NotNull] string target, [CanBeNull] string mimeType)
        {
            #region Sanity checks
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (string.IsNullOrEmpty(target))
            {
                throw new ArgumentNullException("target");
            }
            #endregion

            // Select the correct extractor based on the MIME type
            Extractor extractor;
            switch (mimeType)
            {
            case Model.Archive.MimeTypeZip:
                extractor = new ZipExtractor(stream, target);
                break;

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

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

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

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

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

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

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

            case Model.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);
        }
예제 #2
0
 protected override Stream OpenArchive()
 {
     return(TarBz2Extractor.GetDecompressionStream(base.OpenArchive()));
 }
예제 #3
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;
        }
예제 #4
0
 protected override Stream BuildArchive(string sourcePath) => TarBz2Extractor.GetDecompressionStream(base.BuildArchive(sourcePath));