MCPcopy Create free account
hub / github.com/pydio/cells / CommonRoot

Method CommonRoot

common/proto/tree/node.go:700–732  ·  view source on GitHub ↗
(m2 *MPath)

Source from the content-addressed store, hash-verified

698}
699
700func (m *MPath) CommonRoot(m2 *MPath) *MPath {
701 root := &MPath{}
702
703 if origMPathSegment, targetMPathSegment := m.GetMPath1(), m2.GetMPath1(); origMPathSegment == targetMPathSegment {
704 root.SetMPath1(origMPathSegment)
705 } else {
706 common := std.CommonPrefixLen(origMPathSegment, targetMPathSegment)
707 root.SetMPath1(origMPathSegment[:common])
708 }
709
710 if origMPathSegment, targetMPathSegment := m.GetMPath2(), m2.GetMPath2(); origMPathSegment == targetMPathSegment {
711 root.SetMPath1(origMPathSegment)
712 } else {
713 common := std.CommonPrefixLen(origMPathSegment, targetMPathSegment)
714 root.SetMPath1(origMPathSegment[:common])
715 }
716
717 if origMPathSegment, targetMPathSegment := m.GetMPath3(), m2.GetMPath3(); origMPathSegment == targetMPathSegment {
718 root.SetMPath1(origMPathSegment)
719 } else {
720 common := std.CommonPrefixLen(origMPathSegment, targetMPathSegment)
721 root.SetMPath1(origMPathSegment[:common])
722 }
723
724 if origMPathSegment, targetMPathSegment := m.GetMPath4(), m2.GetMPath4(); origMPathSegment == targetMPathSegment {
725 root.SetMPath1(origMPathSegment)
726 } else {
727 common := std.CommonPrefixLen(origMPathSegment, targetMPathSegment)
728 root.SetMPath1(origMPathSegment[:common])
729 }
730
731 return root
732}
733
734// MPathEquals greater than for where
735type MPathEquals struct {

Callers 1

MoveNodeTreeMethod · 0.80

Calls 10

GetMPath1Method · 0.95
SetMPath1Method · 0.95
GetMPath2Method · 0.95
GetMPath3Method · 0.95
GetMPath4Method · 0.95
CommonPrefixLenFunction · 0.92
GetMPath1Method · 0.65
GetMPath2Method · 0.65
GetMPath3Method · 0.65
GetMPath4Method · 0.65

Tested by

no test coverage detected