Extracts a GZip-compressed TAR archive.
Inheritance: TarExtractor
Ejemplo n.º 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);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
 protected override Stream OpenArchive()
 {
     return(TarGzExtractor.GetDecompressionStream(base.OpenArchive()));
 }
 protected override Stream BuildArchive(string sourcePath) => TarGzExtractor.GetDecompressionStream(base.BuildArchive(sourcePath));