Beispiel #1
0
static std::vector<std::string> FileSearchWithTest(const std::vector<std::string>& directories, bool recursive, std::function<bool(const File::FSTEntry &)> callback)
{
	std::vector<std::string> result;
	for (const std::string& directory : directories)
	{
		File::FSTEntry top = File::ScanDirectoryTree(directory, recursive);

		std::function<void(File::FSTEntry&)> DoEntry;
		DoEntry = [&](File::FSTEntry& entry) {
			if (callback(entry))
				result.push_back(entry.physicalName);
			for (auto& child : entry.children)
				DoEntry(child);
		};
		for (auto& child : top.children)
			DoEntry(child);
	}
	// remove duplicates
	std::sort(result.begin(), result.end());
	result.erase(std::unique(result.begin(), result.end()), result.end());
	return result;
}
Beispiel #2
0
void* Threadable::Entry( void )
{
	srand((unsigned)time(NULL));
	DoEntry();
	
	s_CriticalSection.Enter();
	++s_iCurrentThread;
	if (s_iCurrentThread == THREAD_COUNT)
	{
		s_iCurrentThread = 0;
		DoExit();
		if (m_pCallback)
			m_pCallback->OnThreadsFinish();
	}
	s_CriticalSection.Leave();
	return NULL;
}