CTGitPath CTGitPathList::GetCommonRoot() const { if (IsEmpty()) return CTGitPath(); if (GetCount() == 1) return m_paths[0]; // first entry is common root for itself // (add trailing '\\' to detect partial matches of the last path element) CString root = m_paths[0].GetWinPathString() + _T('\\'); int rootLength = root.GetLength(); // determine common path string prefix for (PathVector::const_iterator it = m_paths.begin() + 1; it != m_paths.end(); ++it) { CString path = it->GetWinPathString() + _T('\\'); int newLength = CStringUtils::GetMatchingLength(root, path); if (newLength != rootLength) { root.Delete(newLength, rootLength); rootLength = newLength; } } // remove the last (partial) path element if (rootLength > 0) root.Delete(root.ReverseFind(_T('\\')), rootLength); // done return CTGitPath(root); }
CString CTGitPathList::CreateAsteriskSeparatedString() const { CString sRet; PathVector::const_iterator it; for(it = m_paths.begin(); it != m_paths.end(); ++it) { if (!sRet.IsEmpty()) sRet += _T("*"); sRet += it->GetWinPathString(); } return sRet; }