/// <summary>
        /// Reads the custom code table, if there is one
        /// </summary>
        void ReadCodeTable()
        {
            // The length given includes the nearSize and sameSize bytes
            int compressedTableLength = IOHelper.ReadBigEndian7BitEncodedInt(delta) - 2;
            int nearSize = IOHelper.CheckedReadByte(delta);
            int sameSize = IOHelper.CheckedReadByte(delta);

            byte[] compressedTableData = IOHelper.CheckedReadBytes(delta, compressedTableLength);

            byte[] defaultTableData = CodeTable.Default.GetBytes();

            MemoryStream tableOriginal = new MemoryStream(defaultTableData, false);
            MemoryStream tableDelta    = new MemoryStream(compressedTableData, false);

            byte[]       decompressedTableData = new byte[1536];
            MemoryStream tableOutput           = new MemoryStream(decompressedTableData, true);

            VcdiffDecoder.Decode(tableOriginal, tableDelta, tableOutput);

            if (tableOutput.Position != 1536)
            {
                throw new VcdiffFormatException("Compressed code table was incorrect size");
            }

            codeTable = new CodeTable(decompressedTableData);
            cache     = new AddressCache(nearSize, sameSize);
        }
Exemplo n.º 2
0
		/// <summary>
		/// Reads the custom code table, if there is one
		/// </summary>
		void ReadCodeTable()
		{
			// The length given includes the nearSize and sameSize bytes
			int compressedTableLength = IOHelper.ReadBigEndian7BitEncodedInt(delta)-2;
			int nearSize = IOHelper.CheckedReadByte(delta);
			int sameSize = IOHelper.CheckedReadByte(delta);
			byte[] compressedTableData = IOHelper.CheckedReadBytes(delta, compressedTableLength);

			byte[] defaultTableData = CodeTable.Default.GetBytes();

			MemoryStream tableOriginal = new MemoryStream(defaultTableData, false);
			MemoryStream tableDelta = new MemoryStream(compressedTableData, false);
			byte[] decompressedTableData = new byte[1536];
			MemoryStream tableOutput = new MemoryStream(decompressedTableData, true);
			VcdiffDecoder.Decode(tableOriginal, tableDelta, tableOutput);

			if (tableOutput.Position != 1536)
			{
				throw new VcdiffFormatException("Compressed code table was incorrect size");
			}

			codeTable = new CodeTable(decompressedTableData);
			cache = new AddressCache(nearSize, sameSize);
		}