コード例 #1
0
ファイル: AddCopyList.cs プロジェクト: pvginkel/VisualGit
        private void GDIFFCopy(Stream Diff, Copy C)
        {
            //Name	Cmd		Followed By			Action
            //-----------------------------------------------------------
            //COPY	249		ushort, ubyte		copy <position>, <length>
            //COPY	250		ushort, ushort		copy <position>, <length>
            //COPY	251		ushort, int			copy <position>, <length>
            //COPY	252		int, ubyte			copy <position>, <length>
            //COPY	253		int, ushort			copy <position>, <length>
            //COPY	254		int, int			copy <position>, <length>
            //COPY	255		long, int			copy <position>, <length>

            if (C.iBaseOffset <= ushort.MaxValue)
            {
                if (C.iLength <= byte.MaxValue)
                {
                    Diff.WriteByte(249);
                    WriteBigEndian(Diff, (ushort)C.iBaseOffset);
                    Diff.WriteByte((byte)C.iLength);
                }
                else if (C.iLength <= ushort.MaxValue)
                {
                    Diff.WriteByte(250);
                    WriteBigEndian(Diff, (ushort)C.iBaseOffset);
                    WriteBigEndian(Diff, (ushort)C.iLength);
                }
                else
                {
                    Diff.WriteByte(251);
                    WriteBigEndian(Diff, (ushort)C.iBaseOffset);
                    WriteBigEndian(Diff, C.iLength);
                }
            }
            else
            {
                if (C.iLength <= byte.MaxValue)
                {
                    Diff.WriteByte(252);
                    WriteBigEndian(Diff, C.iBaseOffset);
                    Diff.WriteByte((byte)C.iLength);
                }
                else if (C.iLength <= ushort.MaxValue)
                {
                    Diff.WriteByte(253);
                    WriteBigEndian(Diff, C.iBaseOffset);
                    WriteBigEndian(Diff, (ushort)C.iLength);
                }
                else
                {
                    Diff.WriteByte(254);
                    WriteBigEndian(Diff, C.iBaseOffset);
                    WriteBigEndian(Diff, C.iLength);
                }
            }
        }
コード例 #2
0
ファイル: BinaryDiff.cs プロジェクト: pvginkel/VisualGit
 protected virtual int EmitCopy(int iBasePos, int iLength, Stream BaseFile, AddCopyList List)
 {
     Copy C = new Copy();
     C.iBaseOffset = iBasePos;
     C.iLength = iLength;
     List.Add(C);
     return iLength;
 }