示例#1
0
 public static void WriteCommand(BinaryWriter s, OutputCommand command)
 {
     if (command.Kind == CommandKind.Literal)
     {
         if (command.Literal.Count <= 64)
         {
             if (command.Literal.Count == 0)
             {
                 throw new ArgumentException("Literal must have at least 1 byte");
             }
             s.Write((byte)command.Literal.Count);
         }
         else
         {
             int  sizeNeeded = GetSizeNeeded((ulong)command.Literal.Count);
             int  num        = SizeToIdx(sizeNeeded);
             byte value      = (byte)(65 + num);
             s.Write(value);
             StreamHelpers.WriteBigEndian(s, (ulong)command.Literal.Count, sizeNeeded);
         }
         s.Write(command.Literal.ToArray());
     }
     else if (command.Kind == CommandKind.Copy)
     {
         int  sizeNeeded2 = GetSizeNeeded(command.Position);
         int  sizeNeeded3 = GetSizeNeeded(command.Length);
         byte b           = SizeToIdx(sizeNeeded2);
         byte b2          = SizeToIdx(sizeNeeded3);
         byte value2      = (byte)(69 + b * 4 + b2);
         s.Write(value2);
         StreamHelpers.WriteBigEndian(s, command.Position, sizeNeeded2);
         StreamHelpers.WriteBigEndian(s, command.Length, sizeNeeded3);
     }
     else if (command.Kind == CommandKind.End)
     {
         s.Write(0);
     }
 }
示例#2
0
 public static void WriteHeader(BinaryWriter s, SignatureJobSettings settings)
 {
     StreamHelpers.WriteBigEndian(s, (uint)settings.MagicNumber);
     StreamHelpers.WriteBigEndian(s, (uint)settings.BlockLength);
     StreamHelpers.WriteBigEndian(s, (uint)settings.StrongSumLength);
 }