nameLength() public method

public nameLength ( ) : int
return int
示例#1
0
        private int ComputeSize(DirCacheEntry[] cache, int cIdx, int pathOffset, ObjectWriter ow)
        {
            int endIdx   = cIdx + _entrySpan;
            int childIdx = 0;
            int entryIdx = cIdx;
            int size     = 0;

            while (entryIdx < endIdx)
            {
                DirCacheEntry e = cache[entryIdx];
                if (e.getStage() != 0)
                {
                    throw new UnmergedPathException(e);
                }

                byte[] ep = e.Path;
                if (childIdx < _childCount)
                {
                    DirCacheTree st = _children[childIdx];
                    if (st.contains(ep, pathOffset, ep.Length))
                    {
                        int stOffset = pathOffset + st.nameLength() + 1;
                        st.writeTree(cache, entryIdx, stOffset, ow);

                        size += FileMode.Tree.copyToLength();
                        size += st.nameLength();
                        size += Constants.OBJECT_ID_LENGTH + 2;

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

                FileMode mode = e.getFileMode();

                size += mode.copyToLength();
                size += ep.Length - pathOffset;
                size += Constants.OBJECT_ID_LENGTH + 2;
                entryIdx++;
            }

            return(size);
        }
示例#2
0
        private void ParseEntry()
        {
            _currentEntry = Cache.getEntry(_pointer);
            byte[] cep = _currentEntry.Path;

            if (_nextSubtreePos != Tree.getChildCount())
            {
                DirCacheTree s = Tree.getChild(_nextSubtreePos);
                if (s.contains(cep, PathOffset, cep.Length))
                {
                    // The current position is the first file of this subtree.
                    // Use the subtree instead as the current position.
                    //
                    _currentSubtree = s;
                    _nextSubtreePos++;

                    if (s.isValid())
                    {
                        s.getObjectId().copyRawTo(SubtreeId, 0);
                    }
                    else
                    {
                        SubtreeId.Fill((byte)0);
                    }

                    Mode = FileMode.Tree.Bits;

                    Path    = cep;
                    PathLen = PathOffset + s.nameLength();
                    return;
                }
            }

            // The current position is a file/symlink/gitlink so we
            // do not have a subtree located here.
            //
            Mode            = _currentEntry.getRawMode();
            Path            = cep;
            PathLen         = cep.Length;
            _currentSubtree = null;
        }