/// <exception cref="System.IO.IOException"></exception> protected internal override bool OnAppendBase(int typeCode, byte[] data, PackedObjectInfo info) { info.SetOffset(packEnd); byte[] buf = Buffer(); int sz = data.Length; int len = 0; buf[len++] = unchecked((byte)((typeCode << 4) | sz & 15)); sz = (int)(((uint)sz) >> 4); while (sz > 0) { buf[len - 1] |= unchecked((int)(0x80)); buf[len++] = unchecked((byte)(sz & unchecked((int)(0x7f)))); sz = (int)(((uint)sz) >> 7); } tailDigest.Update(buf, 0, len); crc.Reset(); crc.Update(buf, 0, len); @out.Seek(packEnd); @out.Write(buf, 0, len); packEnd += len; if (def == null) { def = new Deflater(Deflater.DEFAULT_COMPRESSION, false); } else { def.Reset(); } def.SetInput(data); def.Finish(); while (!def.IsFinished) { len = def.Deflate(buf); tailDigest.Update(buf, 0, len); crc.Update(buf, 0, len); @out.Write(buf, 0, len); packEnd += len; } info.SetCRC((int)crc.GetValue()); return true; }
/// <summary>Construct a PackedObjectInfo instance for this parser.</summary> /// <remarks>Construct a PackedObjectInfo instance for this parser.</remarks> /// <param name="id">identity of the object to be tracked.</param> /// <param name="delta"> /// if the object was previously an unresolved delta, this is the /// delta object that was tracking it. Otherwise null. /// </param> /// <param name="deltaBase"> /// if the object was previously an unresolved delta, this is the /// ObjectId of the base of the delta. The base may be outside of /// the pack stream if the stream was a thin-pack. /// </param> /// <returns>info object containing this object's data.</returns> protected internal virtual PackedObjectInfo NewInfo(AnyObjectId id, PackParser.UnresolvedDelta delta, ObjectId deltaBase) { PackedObjectInfo oe = new PackedObjectInfo(id); if (delta != null) { oe.SetCRC(delta.crc); } return oe; }
/// <exception cref="System.IO.IOException"></exception> protected internal override void OnEndWholeObject(PackedObjectInfo info) { info.SetCRC((int)crc.GetValue()); }