Ejemplo n.º 1
0
 public RarStream(Unpack unpack, FileHeader fileHeader, Stream readStream)
 {
     this.unpack = unpack;
     this.fileHeader = fileHeader;
     this.readStream = readStream;
     fetch = true;
     unpack.doUnpack(fileHeader, readStream, this);
     fetch = false;
 }
Ejemplo n.º 2
0
        internal bool decodeInit(Unpack unpackRead, int escChar)
        {
            int MaxOrder = unpackRead.Char & 0xff;
            bool reset = ((MaxOrder & 0x20) != 0);

            int MaxMB = 0;
            if (reset)
            {
                MaxMB = unpackRead.Char;
            }
            else
            {
                if (subAlloc.GetAllocatedMemory() == 0)
                {
                    return (false);
                }
            }
            if ((MaxOrder & 0x40) != 0)
            {
                escChar = unpackRead.Char;
                unpackRead.PpmEscChar = escChar;
            }
            coder = new RangeCoder(unpackRead);
            if (reset)
            {
                MaxOrder = (MaxOrder & 0x1f) + 1;
                if (MaxOrder > 16)
                {
                    MaxOrder = 16 + (MaxOrder - 16)*3;
                }
                if (MaxOrder == 1)
                {
                    subAlloc.stopSubAllocator();
                    return (false);
                }
                subAlloc.startSubAllocator((MaxMB + 1) << 20);
                minContext = new PPMContext(Heap);
                //medContext = new PPMContext(Heap);
                maxContext = new PPMContext(Heap);
                foundState = new State(Heap);
                dummySEE2Cont = new SEE2Context();
                for (int i = 0; i < 25; i++)
                {
                    for (int j = 0; j < 16; j++)
                    {
                        SEE2Cont[i][j] = new SEE2Context();
                    }
                }
                startModelRare(MaxOrder);
            }
            return (minContext.Address != 0);
        }
Ejemplo n.º 3
0
        public void WriteTo(Stream streamToWriteTo, IExtractionListener listener)
        {
            if (IsEncrypted)
            {
                throw new RarExtractionException("Entry is password protected and cannot be extracted.");
            }

            if (IsDirectory)
            {
                throw new RarExtractionException("Entry is a file directory and cannot be extracted.");
            }

            listener.CheckNotNull("listener");
            listener.OnFileEntryExtractionInitialized(FilePath, CompressedSize);
            using (Stream input = new MultiVolumeReadOnlyStream(parts, listener))
            {
                var pack = new Unpack(FileHeader, input, streamToWriteTo);
                pack.doUnpack(Archive.IsSolidArchive());
            }
        }
Ejemplo n.º 4
0
 internal RangeCoder(Unpack unpackRead)
 {
     this.unpackRead = unpackRead;
     this.Init();
 }
Ejemplo n.º 5
0
 internal bool decodeInit(Unpack unpackRead, int escChar)
 {
     int maxOrder = unpackRead.Char & 0xff;
     bool flag = (maxOrder & 0x20) != 0;
     int num2 = 0;
     if (flag)
     {
         num2 = unpackRead.Char;
     }
     else if (this.subAlloc.GetAllocatedMemory() == 0)
     {
         return false;
     }
     if ((maxOrder & 0x40) != 0)
     {
         escChar = unpackRead.Char;
         unpackRead.PpmEscChar = escChar;
     }
     this.coder = new RangeCoder(unpackRead);
     if (flag)
     {
         maxOrder = (maxOrder & 0x1f) + 1;
         if (maxOrder > 0x10)
         {
             maxOrder = 0x10 + ((maxOrder - 0x10) * 3);
         }
         if (maxOrder == 1)
         {
             this.subAlloc.stopSubAllocator();
             return false;
         }
         this.subAlloc.startSubAllocator((num2 + 1) << 20);
         this.minContext = new PPMContext(this.Heap);
         this.maxContext = new PPMContext(this.Heap);
         this.foundState = new SharpCompress.Compressor.PPMd.H.State(this.Heap);
         this.dummySEE2Cont = new SEE2Context();
         for (int i = 0; i < 0x19; i++)
         {
             for (int j = 0; j < 0x10; j++)
             {
                 this.SEE2Cont[i][j] = new SEE2Context();
             }
         }
         this.startModelRare(maxOrder);
     }
     return (this.minContext.Address != 0);
 }
Ejemplo n.º 6
0
 internal RarArchive(IEnumerable <Stream> streams, Options options, string password) : base(ArchiveType.Rar, streams, options, password)
 {
     this.unpack = new SharpCompress.Compressor.Rar.Unpack();
 }