internal void Write(MemoryStream buf) { var t = new BigEndianBitConverter(); long startposition = buf.Position; var tmpBuffer = t.GetBytes((int)(Ctime / 1000000000L)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((int)(Ctime % 1000000000L)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((int)(Mtime / 1000000000L)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((int)(Mtime % 1000000000L)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((_dev)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((_ino)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((Mode)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((_uid)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((_gid)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); tmpBuffer = t.GetBytes((_size)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); ObjectId.copyRawTo(buf); tmpBuffer = t.GetBytes((_flags)); buf.Write(tmpBuffer, 0, tmpBuffer.Length); buf.Write(_name, 0, _name.Length); long end = startposition + ((8 + 8 + 4 + 4 + 4 + 4 + 4 + 4 + 20 + 2 + _name.Length + 8) & ~7); long remain = end - buf.Position; while (remain-- > 0) { buf.WriteByte(0); } }
public ObjectId WriteTree(Tree t) { var output = new MemoryStream(); var writer = new BinaryWriter(output); foreach (TreeEntry entry in t.Members) { ObjectId id = entry.Id; if (id == null) { throw new ObjectWritingException("object at path \"" + entry.FullName + "\" does not have an id assigned. All object ids must be assigned prior to writing a tree."); } entry.Mode.CopyTo(output); writer.Write((byte)0x20); writer.Write(entry.NameUTF8); writer.Write((byte)0); id.copyRawTo(output); } return(WriteCanonicalTree(output.ToArray())); }