private TreeFormatter Build() { byte[] nameBuf = new byte[Constants.OBJECT_ID_STRING_LENGTH]; int nameLen = Constants.OBJECT_ID_STRING_LENGTH - prefixLen; TreeFormatter fmt = new TreeFormatter(TreeSize(nameLen)); NonNoteEntry e = nonNotes; for (int i = 0; i < cnt; i++) { Note n = notes[i]; n.CopyTo(nameBuf, 0); while (e != null && e.PathCompare(nameBuf, prefixLen, nameLen, FileMode.REGULAR_FILE ) < 0) { e.Format(fmt); e = e.next; } fmt.Append(nameBuf, prefixLen, nameLen, FileMode.REGULAR_FILE, n.GetData()); } for (; e != null; e = e.next) { e.Format(fmt); } return(fmt); }
/// <exception cref="System.IO.IOException"></exception> private TreeFormatter Build(bool insert, ObjectInserter inserter) { byte[] nameBuf = new byte[2]; TreeFormatter fmt = new TreeFormatter(TreeSize()); NonNoteEntry e = nonNotes; for (int cell = 0; cell < 256; cell++) { NoteBucket b = table[cell]; if (b == null) { continue; } nameBuf[0] = hexchar[(int)(((uint)cell) >> 4)]; nameBuf[1] = hexchar[cell & unchecked ((int)(0x0f))]; while (e != null && e.PathCompare(nameBuf, 0, 2, FileMode.TREE) < 0) { e.Format(fmt); e = e.next; } ObjectId id; if (insert) { id = b.WriteTree(inserter); } else { id = b.GetTreeId(); } fmt.Append(nameBuf, 0, 2, FileMode.TREE, id); } for (; e != null; e = e.next) { e.Format(fmt); } return(fmt); }