public PpmdStream(PpmdProperties properties, Stream stream, bool compress)
        {
            this.properties = properties;
            this.stream = stream;
            this.compress = compress;

            if (properties.Version == PpmdVersion.I1)
            {
                model = new I1.Model();
                if (compress)
                    model.EncodeStart(properties);
                else
                    model.DecodeStart(stream, properties);
            }
            if (properties.Version == PpmdVersion.H)
            {
                modelH = new H.ModelPPM();
                if (compress)
                    throw new NotImplementedException();
                else
                    modelH.decodeInit(stream, properties.ModelOrder, properties.AllocatorSize);
            }
            if (properties.Version == PpmdVersion.H7z)
            {
                modelH = new H.ModelPPM();
                if (compress)
                    throw new NotImplementedException();
                else
                    modelH.decodeInit(null, properties.ModelOrder, properties.AllocatorSize);
                decoder = new LZMA.RangeCoder.Decoder();
                decoder.Init(stream);
            }
        }
示例#2
0
 public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment)
     : base(ArchiveType.Zip)
 {
     this.ppmdProperties = new PpmdProperties();
     this.entries = new List<ZipCentralDirectoryEntry>();
     this.zipComment = zipComment ?? string.Empty;
     this.zipCompressionInfo = new ZipCompressionInfo(compressionInfo);
     base.InitalizeStream(destination, false);
 }
示例#3
0
        public PpmdStream(PpmdProperties properties, Stream stream, bool compress)
        {
            this.properties = properties;
            this.stream     = stream;
            this.compress   = compress;

            if (properties.Version == PpmdVersion.I1)
            {
                model = new I1.Model();
                if (compress)
                {
                    model.EncodeStart(properties);
                }
                else
                {
                    model.DecodeStart(stream, properties);
                }
            }
            if (properties.Version == PpmdVersion.H)
            {
                modelH = new H.ModelPPM();
                if (compress)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    modelH.decodeInit(stream, properties.ModelOrder, properties.AllocatorSize);
                }
            }
            if (properties.Version == PpmdVersion.H7z)
            {
                modelH = new H.ModelPPM();
                if (compress)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    modelH.decodeInit(null, properties.ModelOrder, properties.AllocatorSize);
                }
                decoder = new LZMA.RangeCoder.Decoder();
                decoder.Init(stream);
            }
        }
示例#4
0
        private readonly PpmdProperties ppmdProperties; // Caching properties to speed up PPMd.
#endif

        public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment, Encoding encoding = null)
            : base(ArchiveType.Zip)
        {
            this.zipComment = zipComment ?? string.Empty;
            this.encoding = encoding ?? ArchiveEncoding.Default;

            switch (compressionInfo.Type)
            {
                case CompressionType.None:
                    {
                        compression = ZipCompressionMethod.None;
                    }
                    break;
                case CompressionType.Deflate:
                    {
                        compression = ZipCompressionMethod.Deflate;
                        deflateCompressionLevel = compressionInfo.DeflateCompressionLevel;
                    }
                    break;
                case CompressionType.BZip2:
                    {
                        compression = ZipCompressionMethod.BZip2;
                    }
                    break;
#if LZMA
                case CompressionType.LZMA:
                    {
                        compression = ZipCompressionMethod.LZMA;
                    }
                    break;
#endif
#if PPMd
                case CompressionType.PPMd:
                    {
                        ppmdProperties = new PpmdProperties();
                        compression = ZipCompressionMethod.PPMd;
                    }
                    break;
#endif
                default:
                    throw new InvalidFormatException("Invalid compression method: " + compressionInfo.Type);
            }
            InitalizeStream(destination, false);
        }