当前位置: 首页>>代码示例>>C#>>正文


C# ObjectWriter.WriteCanonicalTree方法代码示例

本文整理汇总了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;
        }
开发者ID:stephensong,项目名称:GitSharp,代码行数:67,代码来源:DirCacheTree.cs


注:本文中的ObjectWriter.WriteCanonicalTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。