Example #1
0
        /// <summary>
        /// Sets the preset dictionary.  This should only be called, if
        /// needsDictionary() returns true and it should set the same
        /// dictionary, that was used for deflating.  The getAdler()
        /// function returns the checksum of the dictionary needed.
        /// </summary>
        /// <param name="buffer">
        /// The dictionary.
        /// </param>
        /// <param name="index">
        /// The index into buffer where the dictionary starts.
        /// </param>
        /// <param name="count">
        /// The number of bytes in the dictionary.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// No dictionary is needed.
        /// </exception>
        /// <exception cref="SharpZipBaseException">
        /// The adler checksum for the buffer is invalid
        /// </exception>
        public void SetDictionary(byte[] buffer, int index, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (index < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            if (!IsNeedingDictionary)
            {
                throw new InvalidOperationException("Dictionary is not needed");
            }

            adler?.Update(new ArraySegment <byte>(buffer, index, count));

            if (adler != null && (int)adler.Value != readAdler)
            {
                throw new SharpZipBaseException("Wrong adler checksum");
            }
            adler?.Reset();
            outputWindow.CopyDict(buffer, index, count);
            mode = DECODE_BLOCKS;
        }
Example #2
0
 public void SetDictionary(byte[] buffer, int index, int count)
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     //IL_0017: Unknown result type (might be due to invalid IL or missing references)
     //IL_0026: Unknown result type (might be due to invalid IL or missing references)
     //IL_0039: Unknown result type (might be due to invalid IL or missing references)
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (count < 0)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (!IsNeedingDictionary)
     {
         throw new InvalidOperationException("Dictionary is not needed");
     }
     adler.Update(buffer, index, count);
     if ((int)adler.Value != readAdler)
     {
         throw new SharpZipBaseException("Wrong adler checksum");
     }
     adler.Reset();
     outputWindow.CopyDict(buffer, index, count);
     mode = 2;
 }
Example #3
0
 public void SetDictionary(byte[] buffer, int index, int count)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (count < 0)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (!IsNeedingDictionary)
     {
         throw new InvalidOperationException("Dictionary is not needed");
     }
     adler.Update(buffer, index, count);
     if (((int)adler.Value) != readAdler)
     {
         throw new SharpZipBaseException("Wrong adler checksum");
     }
     adler.Reset();
     outputWindow.CopyDict(buffer, index, count);
     mode = 2;
 }
Example #4
0
        /// <summary>
        /// Sets the preset dictionary.  This should only be called, if
        /// needsDictionary() returns true and it should set the same
        /// dictionary, that was used for deflating.  The getAdler()
        /// function returns the checksum of the dictionary needed.
        /// </summary>
        /// <param name="buffer">
        /// The dictionary.
        /// </param>
        /// <param name="index">
        /// The index into buffer where the dictionary starts.
        /// </param>
        /// <param name="count">
        /// The number of bytes in the dictionary.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// No dictionary is needed.
        /// </exception>
        /// <exception cref="InvalidDataException">
        /// The adler checksum for the buffer is invalid.
        /// </exception>
        public void SetDictionary(byte[] buffer, int index, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (index < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            if (!IsNeedingDictionary)
            {
                throw new InvalidOperationException("Dictionary is not needed");
            }

            adler.Update(buffer, index, count);

            if ((int)adler.Value != readAdler)
            {
                throw new InvalidDataException("Wrong adler checksum");
            }

            adler.Reset();
            outputWindow.CopyDict(buffer, index, count);
            mode = State.Blocks;
        }
Example #5
0
		/// <summary>
		/// Sets the preset dictionary.  This should only be called, if
		/// needsDictionary() returns true and it should set the same
		/// dictionary, that was used for deflating.  The getAdler()
		/// function returns the checksum of the dictionary needed.
		/// </summary>
		/// <param name="buffer">
		/// The dictionary.
		/// </param>
		/// <param name="offset">
		/// The offset into buffer where the dictionary starts.
		/// </param>
		/// <param name="len">
		/// The length of the dictionary.
		/// </param>
		/// <exception cref="System.InvalidOperationException">
		/// No dictionary is needed.
		/// </exception>
		/// <exception cref="SharpZipBaseException">
		/// The adler checksum for the buffer is invalid
		/// </exception>
		public void SetDictionary(byte[] buffer, int offset, int len)
		{
			if (!IsNeedingDictionary) {
				throw new InvalidOperationException();
			}
			
			adler.Update(buffer, offset, len);
			if ((int)adler.Value != readAdler) {
				throw new SharpZipBaseException("Wrong adler checksum");
			}
			adler.Reset();
			outputWindow.CopyDict(buffer, offset, len);
			mode = DECODE_BLOCKS;
		}
Example #6
0
        /// <summary>
        /// Sets the preset dictionary.  This should only be called, if
        /// needsDictionary() returns true and it should set the same
        /// dictionary, that was used for deflating.  The getAdler()
        /// function returns the checksum of the dictionary needed.
        /// </summary>
        /// <param name="buffer">
        /// the dictionary.
        /// </param>
        /// <param name="off">
        /// the offset into buffer where the dictionary starts.
        /// </param>
        /// <param name="len">
        /// the length of the dictionary.
        /// </param>
        /// <exception cref="System.InvalidOperationException">
        /// if no dictionary is needed.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// if the dictionary checksum is wrong.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// if the off and/or len are wrong.
        /// </exception>
        public void SetDictionary(byte[] buffer, int off, int len)
        {
            if (!NeedsDictionary())
            {
                throw new InvalidOperationException();
            }

            adler.Update(buffer, off, len);
            if ((int)adler.Value != readAdler)
            {
                throw new ArgumentException("Wrong adler checksum");
            }
            adler.Reset();
            outputWindow.CopyDict(buffer, off, len);
            mode = DECODE_BLOCKS;
        }