#include "search.h" ////////////////////// // // SearchPath members void SearchPath::add_dir(const list& dlist, int depth) { for(CSiter diter = dlist.begin(); diter != dlist.end(); diter++) add_dir( *diter, depth); } list SearchPath::find_file(const string& fname) //const { // Why does this doens't work ????????? // list result; // for(CSbiter sbiter = sb.begin(); sbiter != sb.end(); sbiter++) { // list ores = (*sbiter)->find_files(fname.c_str()); // result = result + ores; //(*sb)->find_files(fname); // } list result; const list allfiles = all_files(); for(CFiliter i = allfiles.begin(); i != allfiles.end(); i++) if((*i)->fname() == fname) result.push_back((*i)->full_path()); result.unique(); return result; } list SearchPath::find_file(bool (*f)(const string&) ) const { list result; const list allfiles = all_files(); for(CFiliter i = allfiles.begin(); i != allfiles.end(); i++) { const string fpath = (*i)->full_path(); if(f(fpath)) result.push_back(fpath); } result.unique(); return result; } list SearchPath::fc_find_file(const string& fname) const { list result; const list allfiles = all_files(); for(CFiliter i = allfiles.begin(); i != allfiles.end(); i++) if((*i)->fname() == fname) result.push_back(*i); result.unique(); return result; } list SearchPath::fc_find_file(bool (*f) (const string&) ) const { list result; const list allfiles = all_files(); for(CFiliter i = allfiles.begin(); i != allfiles.end(); i++) { const string fpath = (*i)->full_path(); if(f(fpath)) result.push_back(*i); } result.unique(); return result; } // private members list SearchPath::all_files() const { list result; for(CSbiter sbiter = sb.begin(); sbiter != sb.end(); sbiter++) result = result + (*sbiter)->ret_all_files(); return result; }