private static bool NameEqual(AbstractTreeIterator a,
     AbstractTreeIterator b)
 {
     return a.pathCompare(b, TreeMode) == 0;
 }
        private AbstractTreeIterator FastMin()
        {
            _fastMinHasMatch = true;

            int i = 0;
            AbstractTreeIterator minRef = Trees[i];

            while (minRef.eof() && ++i < Trees.Length)
            {
                minRef = Trees[i];
            }

            if (minRef.eof())
            {
                return(minRef);
            }

            minRef.Matches = minRef;
            while (++i < Trees.Length)
            {
                AbstractTreeIterator t = Trees[i];
                if (t.eof())
                {
                    continue;
                }

                int cmp = t.pathCompare(minRef);
                if (cmp < 0)
                {
                    if (_fastMinHasMatch && IsTree(minRef) && !IsTree(t) &&
                        NameEqual(minRef, t))
                    {
                        // We used to be at a tree, but now we are at a file
                        // with the same name. Allow the file to match the
                        // tree anyway.
                        //
                        t.Matches = minRef;
                    }
                    else
                    {
                        _fastMinHasMatch = false;
                        t.Matches        = t;
                        minRef           = t;
                    }
                }
                else if (cmp == 0)
                {
                    // Exact name/mode match is best.
                    //
                    t.Matches = minRef;
                }
                else if (_fastMinHasMatch && IsTree(t) && !IsTree(minRef) &&
                         NameEqual(t, minRef))
                {
                    // The minimum is a file (non-tree) but the next entry
                    // of this iterator is a tree whose name matches our file.
                    // This is a classic D/F conflict and commonly occurs like
                    // this, with no gaps in between the file and directory.
                    //
                    // Use the tree as the minimum instead (see CombineDF).
                    //

                    for (int k = 0; k < i; k++)
                    {
                        AbstractTreeIterator p = Trees[k];
                        if (p.Matches == minRef)
                        {
                            p.Matches = t;
                        }
                    }

                    t.Matches = t;
                    minRef    = t;
                }
                else
                {
                    _fastMinHasMatch = false;
                }
            }

            return(minRef);
        }
 private static bool NameEqual(AbstractTreeIterator a,
                               AbstractTreeIterator b)
 {
     return(a.pathCompare(b, TreeMode) == 0);
 }
Example #4
0
 private static bool nameEqual(AbstractTreeIterator a,
     AbstractTreeIterator b)
 {
     return a.pathCompare(b, TREE_MODE) == 0;
 }