本文整理汇总了C#中ObjectWriter.WriteCanonicalTree方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter.WriteCanonicalTree方法的具体用法?C# ObjectWriter.WriteCanonicalTree怎么用?C# ObjectWriter.WriteCanonicalTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectWriter
的用法示例。
在下文中一共展示了ObjectWriter.WriteCanonicalTree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: writeTree
/**
* Write (if necessary) this tree to the object store.
*
* @param cache
* the complete cache from DirCache.
* @param cIdx
* first position of <code>cache</code> that is a member of this
* tree. The path of <code>cache[cacheIdx].path</code> for the
* range <code>[0,pathOff-1)</code> matches the complete path of
* this tree, from the root of the repository.
* @param pathOffset
* number of bytes of <code>cache[cacheIdx].path</code> that
* matches this tree's path. The value at array position
* <code>cache[cacheIdx].path[pathOff-1]</code> is always '/' if
* <code>pathOff</code> is > 0.
* @param ow
* the writer to use when serializing to the store.
* @return identity of this tree.
* @throws UnmergedPathException
* one or more paths contain higher-order stages (stage > 0),
* which cannot be stored in a tree object.
* @throws IOException
* an unexpected error occurred writing to the object store.
*/
public ObjectId writeTree(DirCacheEntry[] cache, int cIdx, int pathOffset, ObjectWriter ow)
{
if (id == null)
{
int endIdx = cIdx + entrySpan;
int size = computeSize(cache, cIdx, pathOffset, ow);
var @out = new MemoryStream(size);
int childIdx = 0;
int entryIdx = cIdx;
while (entryIdx < endIdx)
{
DirCacheEntry e = cache[entryIdx];
byte[] ep = e.path;
if (childIdx < childCnt)
{
DirCacheTree st = children[childIdx];
if (st.contains(ep, pathOffset, ep.Length))
{
FileMode.Tree.CopyTo(@out);
@out.Write(new byte[] { (byte)' ' }, 0, 1);
@out.Write(st.encodedName, 0, st.encodedName.Length);
@out.Write(new byte[] { (byte)0 }, 0, 1);
st.id.copyRawTo(@out);
entryIdx += st.entrySpan;
childIdx++;
continue;
}
}
e.getFileMode().CopyTo(@out);
@out.Write(new byte[] { (byte)' ' }, 0, 1);
@out.Write(ep, pathOffset, ep.Length - pathOffset);
@out.Write(new byte[] { 0 }, 0, 1);
@out.Write(e.idBuffer(), e.idOffset(), Constants.OBJECT_ID_LENGTH);
entryIdx++;
}
id = ow.WriteCanonicalTree(@out.ToArray());
}
return id;
}