// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include "stdpch.h" #include "add_on_manager.h" using namespace NLMISC; using namespace std; // *************************************************************************** CAddOnManager InterfaceAddOnManager; // *************************************************************************** CAddOnManager::CAddOnManager() { } // *************************************************************************** void CAddOnManager::addSearchFiles(const std::string &path, const std::string &posFilterList, const std::string &negFilterList, NLMISC::IProgressCallback *progressCallBack) { /* NB: this is mainly a copy of CPath::addSearchPath(), with filter added. */ // *** Build filter list std::vector posFilters, negFilters; splitString(posFilterList, ";", posFilters); splitString(negFilterList, ";", negFilters); if(posFilters.empty()) return; // *** AddSearch Path, with Filter features // Progress bar if (progressCallBack) { progressCallBack->progress (0); progressCallBack->pushCropedValues (0, 0.5f); } // find all files in the path and subpaths string newPath = CPath::standardizePath(path); vector filesToProcess; CPath::getPathContent (newPath, true, false, true, filesToProcess, progressCallBack); // Progress bar if (progressCallBack) { progressCallBack->popCropedValues (); progressCallBack->progress (0.5); progressCallBack->pushCropedValues (0.5f, 1); } // add them in the map for (uint f = 0; f < filesToProcess.size(); f++) { // Progress bar if (progressCallBack) { progressCallBack->progress ((float)f/(float)filesToProcess.size()); progressCallBack->pushCropedValues ((float)f/(float)filesToProcess.size(), (float)(f+1)/(float)filesToProcess.size()); } string filename = CFile::getFilename (filesToProcess[f]); string filepath = CFile::getPath (filesToProcess[f]); // positive Filter bool ok= false; for(uint i=0;ipopCropedValues (); } } // Progress bar if (progressCallBack) { progressCallBack->popCropedValues (); } } // *************************************************************************** void CAddOnManager::getFiles(const std::string &filterList, std::vector &files) { files.clear(); // get wildcard list std::vector wildcards; splitString(filterList, ";", wildcards); if(wildcards.empty()) return; // test all files std::set::const_iterator it= _FileSet.begin(); for(;it!=_FileSet.end();it++) { // if only one wildcard match, ok for(uint i=0;i