Beispiel #1
0
void CWords_dicDlg::OnSelchangeResultList() 
{
	// Get selection
	CString resStr;
	m_Results.GetText( m_Results.GetCurSel(), resStr );
	CSString key = Dico.getWordsKey( CSString(resStr) );

	// Copy the selection into the clipboard
	if ( OpenClipboard() )
	{
		HGLOBAL mem = GlobalAlloc (GHND|GMEM_DDESHARE, key.size()+1);
		if (mem)
		{
			char *pmem = (char*)GlobalLock( mem );
			strcpy( pmem, key.c_str() );
			GlobalUnlock( mem );
			EmptyClipboard();
			SetClipboardData( CF_TEXT, mem );
		}
		CloseClipboard();
		if ( mem )
		{
			CString s;
			s.Format( "\"%s\" copied into the clipboard", key.c_str() );
			GetDlgItem( IDC_Status )->SetWindowText( s );
		}
	}
	else
	{
		GetDlgItem( IDC_Status )->SetWindowText( "Cannot access the clipboard" );
	}	
}
Beispiel #2
0
/*
	Some routines for dealing with script input
*/
void setOutputFile(const CSString &filename)
{
	if (Outf!=NULL)
		fclose(Outf);
	Outf=fopen(filename.c_str(), "wt");
	if (Outf == NULL)
	{
		fprintf(stderr, "Can't open output file '%s' ! aborting.", filename.c_str());
		getchar();
		exit(1);
	}
	fields.clear();
}
Beispiel #3
0
// Retourne le numéro du groupe passé en paramètre
int GetNumeroGroupe( const CSString& groupe )
{
	CSString result;
	char buffer[100];
	char buffer2[100];
	int res;

	// *** Get the group number, and add it to group.typ if not already done
	// on recherche si le groupe est présent
	// dans le fichier item_mp_group.typ
	sprintf( buffer, "%s\" Value=\"", groupe.c_str() );
	result = GroupTypContent.splitFrom( buffer );

	// si oui, on retourne son numéro de groupe
	if ( result != "" )
		res = result.splitTo( "\"" ).atoi();
	else
	{
		// sinon, on génère un nouveau numéro :
		// on recupère le dernier numéro de groupe (le max)
		result = GroupTypContent.splitTo( "<LOG>" ).right(10);
		result.splitTo( "\"", true );
		result = result.splitTo( "\"" );

		// on ajoute 1 pour avoir un numéro non utilisé
		res = result.atoi() + 1;

		// on ajoute la nouvelle MP :
		// dans le fichier item_mp_group.typ
		sprintf( buffer, "<DEFINITION Label=\"%s\" Value=\"%d\"/>\n<LOG>", groupe.c_str(), res );
		GroupTypContent= GroupTypContent.replace( "<LOG>", buffer );
		GroupTypContent.writeToFile( ITEM_MP_GROUPE_TYP );
	}


	// *** Add the text in wk.uxt (if not done)
	// Exist in wk.uxt ???
	sprintf( buffer, "mpgroup%d\t", res );
	sprintf( buffer2, "mpgroup%d ", res );
	// if not found
	if ( !WKContent.contains(buffer) && !WKContent.contains(buffer2) )
	{
		// add it at end
		sprintf( buffer, "mpgroup%d\t\t\t[%s]\n\r\nmpSource", res, groupe.c_str() );
		WKContent= WKContent.replace( "\r\nmpSource", buffer );
		WKContent.writeToFile( WK_UXT );
	}

	return res;
}
Beispiel #4
0
/*===========================================================================
 *
 * Class CSrErrorDlg Method - void AddErrorInfo (pError, ErrorIndex);
 *
 *=========================================================================*/
void CSrErrorDlg::AddErrorInfo (CSrError* pError, const int ErrorIndex) {
  CString Buffer;
  CString IndexBuffer;
  int     Length;

  if (ErrorIndex >= 0) IndexBuffer.Format(_T("%d) "), ErrorIndex);

	/* Check for no error information */
  if (pError == NULL) {
    Buffer.Format(_T("%sNo Error!\r\n"), ErrorIndex >= 0 ? IndexBuffer : _T(""));
  }
	/* Fill in error information */
  else {
    CSString ErrorString = pError->GetErrorString();

    Buffer.Format(_T("%s%s\r\n%s%s%s"), ErrorIndex >= 0 ? IndexBuffer : _T(""), pError->GetErrorMessage(), 
	ErrorString.IsEmpty() ? _T("") : _T("\t"),
	ErrorString.c_str(), ErrorString.IsEmpty() ? _T("") : _T("\r\n"));

    ++m_OutputCount;
  }

  Length = m_ErrorDetails.GetWindowTextLength();
  m_ErrorDetails.SetSel(Length, Length, TRUE);
  m_ErrorDetails.ReplaceSel(Buffer, FALSE);
}
Beispiel #5
0
/*
 * Set the result vector with strings corresponding to the input string:
 * - If inputStr is partially or completely found in the keys, all the matching <key,words> are returned;
 * - If inputStr is partially or completely in the words, all the matching <key, words> are returned.
 * The following tags can modify the behaviour of the search algorithm:
 * - ^mystring returns mystring only if it is at the beginning of a key or word
 * - mystring$ returns mystring only if it is at the end of a key or word
 * All returned words are in UTF8.
 */
void CWordsDictionary::lookup( const CSString& inputStr, CVectorSString& resultVec ) const
{
	// Prepare search string
	if ( inputStr.empty() )
		return;

	CSString searchStr = inputStr;
	bool findAtBeginning = false, findAtEnd = false;
	if ( searchStr[0] == '^' )
	{
		searchStr = searchStr.substr( 1 );
		findAtBeginning = true;
	}
	if ( searchStr[searchStr.size()-1] == '$' )
	{
		searchStr = searchStr.rightCrop( 1 );
		findAtEnd = true;
	}

	// Search
	const vector<string> &vec = reinterpret_cast<const vector<string>&>(_Keys);
//	for ( CVectorSString::const_iterator ivs=_Keys.begin(); ivs!=_Keys.end(); ++ivs )
	for ( vector<string>::const_iterator ivs=vec.begin(); ivs!=vec.end(); ++ivs )
	{
		const CSString& key = *ivs;
		string::size_type p;
		if ( (p = key.findNS( searchStr.c_str() )) != string::npos )
		{
			if ( ((!findAtBeginning) || (p==0)) && ((!findAtEnd) || (p==key.size()-searchStr.size())) )
				resultVec.push_back( makeResult( key, _Words[ivs-vec.begin()] ) );
		}
	}
	for ( CVectorSString::const_iterator ivs=_Words.begin(); ivs!=_Words.end(); ++ivs )
	{
		const CSString& word = *ivs;
		string::size_type p;
		if ( (p = word.findNS( searchStr.c_str() )) != string::npos )
		{
			if ( ((!findAtBeginning) || (p==0)) && ((!findAtEnd) || (p==word.size()-searchStr.size())) )
				resultVec.push_back( makeResult( _Keys[ivs-_Words.begin()], word ) );
		}
	}
}
Beispiel #6
0
// Assigne une nouvelle MP à une creature
void AssignerMP( const CSString& creatureName, const CSString& materialName )
{
	// on regarde si la créature est dégénérée ou non
	if ( ( creatureName.c_str()[3] != 'c' ) && ( creatureName.c_str()[3] != 'd' ) 
		&& ( creatureName.c_str()[3] != 'f' ) && ( creatureName.c_str()[3] != 'j' )
		&& ( creatureName.c_str()[3] != 'l' ) && ( creatureName.c_str()[3] != 'p' ) )
	{
	}
	else
	{
		// lecture du fichier d'assignement
		CSString fileName = toString( "%s//_%s_mp.creature", RAW_MATERIAL_ASSIGN.c_str(), creatureName.c_str() ); 
		CSString data;

		// création si le fichier n'existe pas
		if(!CFile::fileExists(fileName))
		{
			CSString	str;
			str = "<?xml version=\"1.0\"?>\r\n";
			str+= "<FORM Version=\"0.0\" State=\"modified\">\r\n";
			str+= "  <STRUCT>\r\n";
			str+= "    <STRUCT Name=\"Harvest\">\r\n";
			str+= "    </STRUCT>\r\n";
			str+= "  </STRUCT>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "</FORM>\r\n";
			str.writeToFile( fileName );
		}

		// lecture
		data.readFromFile( fileName );

		if ( !data.contains( materialName.c_str() ) )
		{	
			// on recherche le premier numéro de MP non utilisé
			CSString str = data;
			int nb= 0;
			while ( str.contains( "Name=\"MP" ) )
			{
				str = str.splitFrom( "Name=\"MP" );
				nb = str.firstWord().atoi();
			}

			// on insère la nouvelle MP
			str = "      <STRUCT Name=\"MP";
			str += toString( "%d\">\r\n        <ATOM Name=\"AssociatedItem\"", nb+1 );
			str += toString( " Value=\"%s\"/>\r\n      </STRUCT>\r\n    </STRUCT>\r\n  </STRUCT>\r\n", materialName.c_str() );
			
			data = data.replace( "    </STRUCT>\r\n  </STRUCT>\r\n", str.c_str() );
			data.writeToFile( fileName );
		}
	}
}
Beispiel #7
0
int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValue)
{
	CSString s;
	bool b;

	b=getPropertyString(s,node,property);
	if (b==false)
		return defaultValue;

	s=s.strip();
	sint val=s.atoi();
	if (val==0 && s!="0")
	{
		nlwarning("bad integer value: %s",s.c_str());
		return defaultValue;
	}

	return val;
}
void RemoveExtensionString(CSString& Filename)
{
	const char* pParse = Filename.c_str();
	int Index = Filename.GetLength() - 1;

	while (Index >= 0)
	{
		if (pParse[Index] == '.')
		{
			Filename.Truncate(Index);
			return;
		}
		else if (pParse[Index] == '\\' || pParse[Index] == '/' || pParse[Index] == ':')
		{
			return;
		}

		--Index;
	}

}
Beispiel #9
0
bool CCharScanScriptCommandRegistry::execute(CCharScanScriptFile& scriptFile,const CSString& commandLine,CCharScanScript* container)
{
	// split the command line into its constituent parts
	CSString theCommand= commandLine.firstWordConst();
	CSString theRawArgs= commandLine.tailFromFirstWord().strip();
	CVectorSString theArgs;
	theRawArgs.splitByOneOfSeparators(" \t",theArgs,false,false,false,false,true);

	// try to locate and execute the given command
	for (uint32 i=0;i<_ScriptCommands.size();++i)
	{
		if (theCommand==_ScriptCommands[i]->getName())
		{
			return _ScriptCommands[i]->execute(scriptFile,theArgs,theRawArgs,commandLine,container);
		}
	}

	// we failed to find the command so bomb
	nlwarning("Unknown script command '%s' in line: %s",theCommand.c_str(),commandLine.c_str());
	return false;
}
Beispiel #10
0
bool SrFindSubDataPath (const char* pFilename, CSString& OutputPath, CSString& OutputFilename, CSString& OutputExtension)
{
	CSString Path;
	int      Index;

	SplitFilenameString(pFilename, Path, OutputFilename, OutputExtension);

	Index = Path.FindRI("\\data\\");

	if (Index >= 0)
		++Index;
	else if (Index < 0 && Path.StartsWithI("data\\")) 
		Index = 0;

	if (Index < 0) 
	{
		OutputPath.Empty();
		return false;
	}

	OutputPath.Copy(Path.c_str() + Index + 5, Path.GetLength() - Index - 5);
	return true;
}
bool CSrEspFile::SaveLocalStrings(const char* pFilename)
{
	bool Result;

	if (m_pHeader == NULL) return true;
	if (!m_pHeader->IsLocalStrings()) return true;
	
	CSString Pathname = CreateSrStringPathname(pFilename);
	int iResult = _mkdir(Pathname);
	if (iResult == -1 && errno != EEXIST) return  AddSrGeneralError("Failed to create the string path '%s'!", Pathname.c_str());

	Result = m_ILStringFile.Save(CreateSrStringFilename(pFilename, "ilstrings"), "ilstrings");
	if (!Result) return AddSrGeneralError("Failed to save the ILSTRING file for '%s'!", pFilename);

	Result = m_DLStringFile.Save(CreateSrStringFilename(pFilename, "dlstrings"), "dlstrings");
	if (!Result) return AddSrGeneralError("Failed to save the DLSTRING file for '%s'!", pFilename);

	Result = m_LStringFile.Save(CreateSrStringFilename(pFilename, "strings"), "strings");
	if (!Result) return AddSrGeneralError("Failed to save the STRING file for '%s'!", pFilename);

	return true;
}
Beispiel #12
0
// Pour une MP se trouvant sur un créature, génération de ses items
void GenerateCreatureItems( int numMP, CSString& nomMP, const MPCraftStats& craftStats )
{
	map<CSString, ListeCreatureMP>::const_iterator itLCMP;
	int quality;
	static int statQuality[] = { 0, 1, 0, 1, 3, 6, 4, 2 };

	// On obtient la liste des niveau d'item à generer pour la créature
	itLCMP = itemsAGenerer.find( nomMP.firstWord() );

	if ( itLCMP != itemsAGenerer.end() )
	{
		ListeCreatureMP::const_iterator itMP = (*itLCMP).second.begin();

		// pour chaque niveau d'item à générer
		while ( itMP != (*itLCMP).second.end() )
		{
			// on enregistre ses caractéristiques
			char eco = (*itMP)->eco;
			int creatureLevel = (*itMP)->creatureLevel;
			int itemLevel = (*itMP)->itemLevel;
			CSString creatureFileName = "c";
			creatureFileName += (*itMP)->codeCreature.toLower();
			
			if ( craftStats.Craft != "" )
			{
				quality = statQuality[creatureLevel-1];
				if ( quality != 6 )
				{						
					if ( quality < 2 )
					{
						CreateSheet( numMP, nomMP, creatureFileName, 'c', quality, craftStats );

						AssignerMP( (*itMP)->creatureFileName, 
							toString( "m%04d%s%c%c01.sitem", numMP, creatureFileName.c_str(), 'c', 'a' + quality ) );
					}
					else
					{
						CreateSheet( numMP, nomMP, creatureFileName, eco, quality, craftStats );

						AssignerMP( (*itMP)->creatureFileName, 
							toString( "m%04d%s%c%c01.sitem", numMP, creatureFileName.c_str(), eco, 'a' + quality ) );
					}

					currentDocItem.push( DtCreature, (*itMP)->creatureFileName );
				}
			}
			else
			{
				// pas de MP de mission pour les boss
				if ( creatureLevel < 5 )
				{
					CreateSheet( numMP, nomMP, creatureFileName, eco, itemLevel, craftStats ); 

					AssignerMP( (*itMP)->creatureFileName, 
							toString( "m%04d%s%c%c01.sitem", numMP, creatureFileName.c_str(), eco, 'a' + itemLevel ) );

					currentDocItem.push( DtCreature, (*itMP)->creatureFileName );
				}
			}

			itMP++;
		}
	}
}
Beispiel #13
0
// Création d'une fiche d'item
void CreateSheet( int numMP, const CSString& nomMP,
				  const CSString& code, char eco,  
				  int level, const MPCraftStats& craftStats,
				  bool specialItem = false, int variation = 1 )
{
	CSString output, directory, itemName, craftInfo, color;
	CSString outputFileName, ecoStr;
	char chaineNum[5];
	bool creature = ( code != "dxa" ) && ( code != "cxx" ) && ( code != "ixx" );

	// Creation du nom de fichier
	sprintf( chaineNum, "%04d", numMP );

	switch ( eco )
	{
	case 'd' :
		directory = "desert";
		ecoStr = "Desert";
		break;

	case 'f' :
		directory = "forest";
		ecoStr = "Forest";
		break;

	case 'j' :
		directory = "jungle";
		ecoStr = "Jungle";
		break;

	case 'l' :
		directory = "lacustre";
		ecoStr = "Lacustre";
		break;

	case 'p' :
		directory = "prime_roots";
		ecoStr = "PrimeRoots";
		break;

	default :
		directory = "common";
		ecoStr = "Common";
		eco = 'c';
		break;
	}

	if ( ( eco == 'c' ) && creature && ( craftStats.Craft == "" ) )
		return;

	outputFileName = toString( "m%04d%s%c%c%02d.sitem", numMP, code.c_str(), eco, 
		                     'a' + level, variation );

	if ( craftStats.Craft == "" )
	{
		CSString levelZone = toString( "%c", 'a' + level );
		currentDocItem.push( DtLevelZone, levelZone.toUpper() );
	}
	else
		currentDocItem.push( DtLevelZone, "-" );
	
	// remplissage des informations de la fiche
	output = "<?xml version=\"1.0\"?>\n<FORM Version=\"0.0\" State=\"modified\">\n";
	output += "  <PARENT Filename=\"_m";
	output += eco;
	output += ".sitem\"/>\n  <PARENT Filename=\"_m";
	output += chaineNum;
	output += ".sitem\"/>\n";

	// le code est celui d'une créature, on doit donc rajouter le parent
	if ( creature )
	{
		output += "  <PARENT Filename=\"_m"; 
		output += code;
		output += ".sitem\"/>\n";
		creature = true;
	}

	output += "  <STRUCT>\n";


    output += "    <STRUCT Name=\"mp\">\n";
	output += "      <ATOM Name=\"MpColor\" Value=\"";
	
	// materiaux de missions toujours Beige
	if ( craftStats.Craft == "" )
	{
		output += "Beige\"/>\n";
		if(craftStats.UsedAsCraftRequirement)
			output += "      <ATOM Name=\"UsedAsCraftRequirement\" Value=\"true\"/>\n";
	}
	else
	{
		// on récupère la couleur
		GetItemColor( craftStats.color, eco, level, color );
		output += color;
		output += "\"/>\n";

		currentDocItem.push( DtColor, color );

		// on ajoute les données de craft
		output += "      <STRUCT Name=\"MpParam\">\n";
		for ( uint i=0; i<craftStats.Craft.size(); i++ )
		{
			int bestStat, worstStat1, worstStat2;

			if ( i == 0 )
			{
				bestStat = craftStats.bestStatA;
				worstStat1 = craftStats.worstStatA1;
				worstStat2 = craftStats.worstStatA2;
			}
			else if ( i == 1 )
			{
				bestStat = craftStats.bestStatB;
				worstStat1 = craftStats.worstStatB1;
				worstStat2 = craftStats.worstStatB2;
			}
			else
			{
				bestStat = -1;
				worstStat1 = -1;
				worstStat2 = -1;
			}

			currentDocItem.push( DtProp, toString( "%c", craftStats.Craft.c_str()[i] ).c_str() );
			
			FillCraftData( craftStats.Craft.c_str()[i], eco, level, creature, bestStat, 
					   worstStat1, worstStat2, craftInfo );
			output += craftInfo;
		}

		output += "      </STRUCT>\n";
	}

	output += "      <ATOM Name=\"MaxQuality\" Value=\"";
	if ( creature || specialItem || ( code == "cxx" ) )
	{
		CSString maxQuality = toString( "%d", 250 ); 
		output += maxQuality;
		currentDocItem.push( DtMaxLevel, maxQuality );
	}
	else
	{
		CSString maxQuality = toString( "%d", GetMaxQuality( level ) );
		output += maxQuality;
		currentDocItem.push( DtMaxLevel, maxQuality );
	}

	output += "\"/>\n      <ATOM Name=\"StatEnergy\" Value=\"";

	CSString statEnergy;
	if ( ( variation == 2 ) && ( numMP == 695 ) ) // cas particulier pour le kitin trophy (beurk)
		statEnergy = "0";
	else if ( !creature || ( craftStats.Craft == "" ) )
		statEnergy = toString( "%d", GetStatEnergy( level ) );
	else if ( variation < 2 )
		statEnergy = toString( "%d", GetStatEnergy( level + 1 ) );
		
	output += statEnergy;
	currentDocItem.push( DtAverageEnergy, statEnergy );

	output += "\"/>\n    </STRUCT>\n  </STRUCT>\n  <STRUCT/>\n  <STRUCT/>\n  <STRUCT/>\n  <STRUCT/>\n</FORM>\n";

	output.writeToFile( toString( "%s%s\\%s", MP_DIRECTORY.c_str(), directory.c_str(), outputFileName.c_str() ) );

	// Génération des noms
	if ( !specialItem )
	{
		outputFileName = toString( "m%04d%s%c%c%02d", numMP, code.c_str(), eco, 'a' + level, variation );
		output = outputFileName;

		GenerateItemNames( nomMP, eco, level, ( craftStats.Craft == "" ), creature, itemName );
		output += "\t" + itemName;
		itemNames.insert( output );
	}

	currentDocItem.push( DtEcosystem, ecoStr );
	currentDocItem.push( DtName, outputFileName );

	SortableData.updateItemAppend( currentDocItem, DtName );
	currentDocItem.reset( DtName );
	currentDocItem.reset( DtEcosystem );
	currentDocItem.reset( DtMaxLevel );
	currentDocItem.reset( DtAverageEnergy );
	currentDocItem.reset( DtTitle );
	currentDocItem.reset( DtLevelZone );
	currentDocItem.reset( DtStatQuality );
	currentDocItem.reset( DtCraftSlotName );
	currentDocItem.reset( DtCraftCivSpec );
	currentDocItem.reset( DtColor );
}
Beispiel #14
0
// Charge les différentes Customized Properties 
// définies dans raw_material_generation.cfg
void LoadCustomizedProperties()
{
	CSString data, name, prop, val;
	
	printf( "-- REGISTERING CUSTOMIZED PROPERTIES --\n" );
	
	data.readFromFile( "raw_material_generation.cfg" );
	data = data.splitFrom( "{\r\n\t" );
	CPath::addSearchPath( MP_DIRECTORY, true, false );

	while ( data.contains( "};" ) )
	{
		name = data.splitTo( ",", true ).replace( "\"", "" );
		prop = data.splitTo( ",", true ).replace( "\"", "" ).replace( " ", "" );

		val = data.splitTo( ",", true ).replace( "\"", "" ).replace( " ", "" );
		if ( val.contains( "\r\n" ) )
			val = val.splitTo( "\r\n", true );

		TRMItem item;
		item.push( DtName, name );
		item.push( DtCustomizedProperties, prop );
		SortableData.updateItemAppend( item, DtName );
		
		data.splitTo( "\t", true );

		CSString fileName, str, output;
		fileName = CPath::lookup( name, false, false, true );
		
		// on vérifie que le fichier concerné existe
		if ( fileName != "" )
		{
			CSString zone = prop.splitTo( ".", true );
			str.readFromFile( fileName );

			if ( !str.contains( zone.c_str() ) )
			{
				output = "<STRUCT>\n    <STRUCT Name=\"";
				output += toString( "%s\">\n      <ATOM Name=\"", zone.c_str() );
				output += toString( "%s\" Value=\"%s\"/>\n    </STRUCT>", prop.c_str(), val.c_str() );

				// on vérifie que la propriétés n'a pas déjà été insérée
				if ( !str.contains( output.c_str() ) )
				{
					str = str.replace( "<STRUCT>", output.c_str() );
					str.writeToFile( fileName );
				}
			}
			else
			{
				output = toString( "    <STRUCT Name=\"%s\">\n", zone.c_str() );
				output += toString( "      <ATOM Name=\"" );
				output += toString( "%s\" Value=\"%s\"/>\n", prop.c_str(), val.c_str() );

				// on vérifie que la propriétés n'a pas déjà été insérée
				if ( !str.contains( toString( "%s\" Value=\"%s\"/>\n", prop.c_str(), val.c_str() ).c_str() ) )
				{
					str = str.replace( toString( "    <STRUCT Name=\"%s\">\n", zone.c_str() ).c_str(), output.c_str() );
					str.writeToFile( fileName );
				}
			}
		}
	}
}
Beispiel #15
0
//void executeScriptBuf(char *txt)
void executeScriptBuf(const string &text)
{
	CSString buf = text;
	CVectorSString	lines;

	vector<string>	tmpLines;
	NLMISC::explode(std::string(buf.c_str()), std::string("\n"), tmpLines, true);
	lines.resize(tmpLines.size());
	for (uint i=0; i<tmpLines.size();i++)
	{
		lines[i]= tmpLines[i];
	}

	for (uint i=0; i<lines.size(); ++i)
	{
		CSString line = lines[i];
		line = line.strip();
		if (line.empty() || line.find("//") == 0)
		{
			// comment or empty line, skip
			continue;
		}
		CSString command = line.strtok(" \t");
		line = line.strip();

		
		if (command == "DFNPATH")
		{
			//CPath::getPathContent(args,true,false,true,files);
			CPath::addSearchPath(line, true, false); // for the dfn files
		}
		else if (command == "PATH")
		{
			files.clear();
			CPath::getPathContent(line, true,false,true,files);
			CPath::addSearchPath(line, true, false); // for the dfn files
		}
		else if (command == "OUTPUT")
		{
			setOutputFile(line);
		}
		else if (command == "FIELD")
		{
			addField(line);
		}
		else if (command == "SOURCE")
		{
			addSource(line);
		}
		else if (command == "SCANFILES")
		{
			scanFiles(line);
		}
		else if (command == "SCRIPT")
		{
			executeScriptFile(line);
		}
		else
		{
			fprintf(stderr,"Unknown command: '%s' '%s'\n", command.c_str(), line.c_str());
		}
	}

	
}
Beispiel #16
0
void buildFileVector(std::vector<std::string> &filenames, const std::string &filespec)
{
	uint i,j;
	// split up the filespec into chains
	CSString filters = filespec;
	filters.strip();
	std::vector<std::string> in, out;

	while (!filters.empty())
	{
		CSString filter = filters.strtok(" \t");
		if (filter.empty())
			continue;

		switch (filter[0])
		{
		case '+':
			in.push_back(filter.leftCrop(1)); break;
			break;
		case '-':
			out.push_back(filter.leftCrop(1)); break;
			break;
		default:
			fprintf(stderr,"Error in '%s' : filter must start with '+' or '-'\n",
				filter.c_str());
			getchar(); 
			exit(1);
		}
	}

/*	for (i=0;i<filespec.size();)
	{
		for (j=i;j<filespec.size() && filespec[j]!=' ' && filespec[j]!='\t';j++) {}
		switch(filespec[i])
		{
		case '+': 
			in.push_back(filespec.substr(i+1,j-i-1)); break;
		case '-': 
			out.push_back(filespec.substr(i+1,j-i-1)); break;
		default: 
			fprintf(stderr,"Filter must start with '+' or '-'\n",&(filespec[i])); getchar(); exit(1);
		}
		i=j;
		while (i<filespec.size() && (filespec[i]==' ' || filespec[i]=='\t')) i++; // skip white space
	}
*/
	// use the filespec as a filter while we build the sheet file vector
	for (i=0;i<files.size();i++)
	{
		bool ok=true;

		// make sure the filename includes all of the include strings
		for (j=0;j<in.size() && ok;j++)
		{
			if (!testWildCard(CFile::getFilename(files[i]), in[j]))
			{
				ok=false;
			}
		}

		// make sure the filename includes none of the exclude strings
		for (j=0;j<out.size() && ok;j++)
		{
			if (testWildCard(CFile::getFilename(files[i]), out[j]))
			{
				ok=false;
			}
		}

		// if the filename matched all of the above criteria then add it to the list
		if (ok)
		{
			printf("Added: %s\n",CFile::getFilename(files[i]).c_str());
			filenames.push_back(files[i]);
		}
	}
	printf("Found: %zu matching files (from %zu)\n",filenames.size(),files.size());

}