idOffset() публичный Метод

public idOffset ( ) : int
Результат int
Пример #1
0
        public override int idOffset()
        {
            if (_currentSubtree != null)
            {
                return(0);
            }

            if (_currentEntry != null)
            {
                return(_currentEntry.idOffset());
            }

            return(0);
        }
Пример #2
0
        ///	<summary>
        /// Write (if necessary) this tree to the object store.
        ///	</summary>
        ///	<param name="cacheEntry">the complete cache from DirCache.</param>
        ///	<param name="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>
        ///	<param name="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>
        ///	<param name="ow">
        /// the writer to use when serializing to the store.
        /// </param>
        ///	<returns>identity of this tree.</returns>
        ///	<exception cref="UnmergedPathException">
        /// one or more paths contain higher-order stages (stage > 0),
        /// which cannot be stored in a tree object.
        /// </exception>
        ///	<exception cref="IOException">
        /// an unexpected error occurred writing to the object store.
        /// </exception>
        public ObjectId writeTree(DirCacheEntry[] cacheEntry, int cIdx, int pathOffset, ObjectWriter ow)
        {
            if (_id == null)
            {
                int endIdx   = cIdx + _entrySpan;
                int size     = ComputeSize(cacheEntry, cIdx, pathOffset, ow);
                var @out     = new MemoryStream(size);
                int childIdx = 0;
                int entryIdx = cIdx;

                while (entryIdx < endIdx)
                {
                    DirCacheEntry e  = cacheEntry[entryIdx];
                    byte[]        ep = e.Path;
                    if (childIdx < _childCount)
                    {
                        DirCacheTree st = _children[childIdx];
                        if (st.contains(ep, pathOffset, ep.Length))
                        {
                            FileMode.Tree.CopyTo(@out);
                            @out.Write(new[] { (byte)' ' }, 0, 1);
                            @out.Write(st._encodedName, 0, st._encodedName.Length);
                            @out.Write(new[] { (byte)0 }, 0, 1);
                            st._id.copyRawTo(@out);

                            entryIdx += st._entrySpan;
                            childIdx++;
                            continue;
                        }
                    }

                    e.getFileMode().CopyTo(@out);
                    @out.Write(new[] { (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);
        }