bool CDirectoryWatcher::RemovePathAndChildren(const CTGitPath& path) { bool bRemoved = false; AutoLocker lock(m_critSec); repeat: for (int i=0; i<watchedPaths.GetCount(); ++i) { if (path.IsAncestorOf(watchedPaths[i])) { watchedPaths.RemovePath(watchedPaths[i]); bRemoved = true; goto repeat; } } return bRemoved; }
bool CDirectoryWatcher::CloseHandlesForPath(const CTGitPath& path) { if (watchInfoMap.size() == 0) return false; AutoLocker lock(m_critSec); for (std::map<HANDLE, CDirWatchInfo *>::iterator I = watchInfoMap.begin(); I != watchInfoMap.end(); ++I) { CDirectoryWatcher::CDirWatchInfo * info = I->second; CTGitPath p = CTGitPath(info->m_DirPath); if (path.IsAncestorOf(p)) { RemovePathAndChildren(p); BlockPath(p); } info->CloseDirectoryHandle(); } watchInfoMap.clear(); if (m_hCompPort != INVALID_HANDLE_VALUE) CloseHandle(m_hCompPort); m_hCompPort = INVALID_HANDLE_VALUE; return true; }
bool CDirectoryWatcher::CloseHandlesForPath(const CTGitPath& path) { AutoLocker lock(m_critSec); CloseWatchHandles(); if (watchInfoMap.empty()) return false; for (TInfoMap::iterator I = watchInfoMap.begin(); I != watchInfoMap.end(); ++I) { CDirectoryWatcher::CDirWatchInfo * info = I->second; I->second = NULL; CTGitPath p = CTGitPath(info->m_DirPath); if (path.IsAncestorOf(p)) { RemovePathAndChildren(p); BlockPath(p); } ScheduleForDeletion(info); } watchInfoMap.clear(); return true; }
bool CTGitPath::CheckChild(const CTGitPath &parent, const CTGitPath& child) { return parent.IsAncestorOf(child); }