Example #1
0
CTGitPath CDirectoryWatcher::CloseInfoMap(HANDLE hDir)
{
	AutoLocker lock(m_critSec);
	TInfoMap::const_iterator d = watchInfoMap.find(hDir);
	if (d != watchInfoMap.end())
	{
		CTGitPath root = CTGitPath(CTGitPath(d->second->m_DirPath).GetRootPathString());
		RemovePathAndChildren(root);
		BlockPath(root);
	}
	CloseWatchHandles();

	CTGitPath path;
	if (watchInfoMap.empty())
		return path;

	for (TInfoMap::iterator I = watchInfoMap.begin(); I != watchInfoMap.end(); ++I)
	{
		CDirectoryWatcher::CDirWatchInfo * info = I->second;

		ScheduleForDeletion (info);
	}
	watchInfoMap.clear();

	return path;
}
Example #2
0
		BlockPath BlockPath::Index(size_t blockIndex) {
			std::array<uint16_t, NODE_MAX_BLOCK_PATH> components;
			components.fill(0);
			
			if (blockIndex < BLOCK_COUNT(0)) {
				// Direct reference.
				components.at(0) = blockIndex;
				return BlockPath(1, components);
			}
			
			if (blockIndex < BLOCK_COUNT(1)) {
				// Single indirect.
				components.at(0) = NODE_SINGLE_INDIRECT_INDEX;
				components.at(1) = indirectOffset<0>(blockIndex);
				return BlockPath(2, components);
			}
			
			if (blockIndex < BLOCK_COUNT(2)) {
				// Double indirect.
				components.at(0) = NODE_DOUBLE_INDIRECT_INDEX;
				components.at(1) = indirectOffset<1>(blockIndex);
				components.at(2) = indirectOffset<0>(blockIndex);
				return BlockPath(3, components);
			}
			
			if (blockIndex < BLOCK_COUNT(3)) {
				// Triple indirect.
				components.at(0) = NODE_TRIPLE_INDIRECT_INDEX;
				components.at(1) = indirectOffset<2>(blockIndex);
				components.at(2) = indirectOffset<1>(blockIndex);
				components.at(3) = indirectOffset<0>(blockIndex);
				return BlockPath(4, components);
			}
			
			throw std::runtime_error("Block index exceeds triple indirect.");
		}
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;
}
Example #4
0
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;
}
CTGitPath CDirectoryWatcher::CloseInfoMap(HDEVNOTIFY hdev)
{
	CTGitPath path;
	if (watchInfoMap.size() == 0)
		return path;
	AutoLocker lock(m_critSec);
	for (std::map<HANDLE, CDirWatchInfo *>::iterator I = watchInfoMap.begin(); I != watchInfoMap.end(); ++I)
	{
		CDirectoryWatcher::CDirWatchInfo * info = I->second;
		if (info->m_hDevNotify == hdev)
		{
			path = info->m_DirName;
			RemovePathAndChildren(path);
			BlockPath(path);
		}
		info->CloseDirectoryHandle();
	}
	watchInfoMap.clear();
	if (m_hCompPort != INVALID_HANDLE_VALUE)
		CloseHandle(m_hCompPort);
	m_hCompPort = INVALID_HANDLE_VALUE;
	return path;
}
Example #6
0
		BlockPath BlockPath::parent() const {
			assert(size() > 0);
			return BlockPath(size() - 1, components_);
		}
Example #7
0
		BlockPath BlockPath::Root() {
			return BlockPath();
		}