Ejemplo n.º 1
0
void ADLSearchManager::matchRecurse(DestDirList &aDestList, DirectoryListing::Directory* aDir, string &aPath) {
	for(DirectoryListing::Directory::Iter dirIt = aDir->directories.begin(); dirIt != aDir->directories.end(); ++dirIt) {
		string tmpPath = aPath + "\\" + (*dirIt)->getName();
		matchesDirectory(aDestList, *dirIt, tmpPath);
		matchRecurse(aDestList, *dirIt, tmpPath);
	}
	for(DirectoryListing::File::Iter fileIt = aDir->files.begin(); fileIt != aDir->files.end(); ++fileIt) {
		matchesFile(aDestList, *fileIt, aPath);
	}
	stepUpDirectory(aDestList);
}
Ejemplo n.º 2
0
void ADLSearchManager::matchRecurse(DestDirList &aDestList, DirectoryListing::Directory* aDir, string &aPath) {
    for(auto& dirIt: aDir->directories) {
        string tmpPath = aPath + "\\" + dirIt->getName();
        matchesDirectory(aDestList, dirIt, tmpPath);
        matchRecurse(aDestList, dirIt, tmpPath);
    }

    for(auto& fileIt: aDir->files) {
        matchesFile(aDestList, fileIt, aPath);
    }

    stepUpDirectory(aDestList);
}
Ejemplo n.º 3
0
void ADLSearchManager::matchesFile(DestDirList& destDirVector, DirectoryListing::File *currentFile, const string& fullPath)
{
	// Add to any substructure being stored
	for (auto id = destDirVector.begin(); id != destDirVector.end(); ++id)
	{
		if (id->subdir != NULL)
		{
			auto copyFile = new DirectoryListing::File(*currentFile, true);
			copyFile->setFlags(currentFile->getFlags());
			dcassert(id->subdir->getAdls());
			
			id->subdir->m_files.push_back(copyFile);
		}
		id->fileAdded = false;  // Prepare for next stage
	}
	
	// Prepare to match searches
	if (currentFile->getName().size() < 1)
	{
		return;
	}
	
	string filePath = fullPath + "\\" + currentFile->getName();// TODO Crash
	// Match searches
	for (auto is = collection.cbegin(); is != collection.cend(); ++is)
	{
		if (destDirVector[is->ddIndex].fileAdded)
		{
			continue;
		}
		if (is->matchesFile(currentFile->getName(), filePath, currentFile->getSize()))
		{
			auto copyFile = new DirectoryListing::File(*currentFile, true);
			copyFile->setFlags(currentFile->getFlags());
#ifdef IRAINMAN_INCLUDE_USER_CHECK
			if (is->isForbidden && !getSentRaw())
			{
				AutoArray<char> buf(FULL_MAX_PATH);
				_snprintf(buf, FULL_MAX_PATH, CSTRING(CHECK_FORBIDDEN), currentFile->getName().c_str());
				
				ClientManager::setClientStatus(user, buf.data(), is->raw, false);
				
				setSentRaw(true);
			}
#endif
			
			destDirVector[is->ddIndex].dir->m_files.push_back(copyFile);
			destDirVector[is->ddIndex].fileAdded = true;
			
			if (is->isAutoQueue)
			{
				try
				{
					QueueManager::getInstance()->add(0,/* [-] IRainman needs for support download to specify extension dir. SETTING(DOWNLOAD_DIRECTORY) + */currentFile->getName(),
					                                 currentFile->getSize(), currentFile->getTTH(), getUser()/*, Util::emptyString*/);
				}
				catch (const Exception& e)
				{
					LogManager::message("QueueManager::getInstance()->add Error = " + e.getError());
				}
			}
			
			if (breakOnFirst)
			{
				// Found a match, search no more
				break;
			}
		}
	}
}