[Compbench-devel] CompBenchmarks++/System System.cpp, 1.13, 1.14 System.h, 1.13, 1.14
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2006-12-28 18:14:24
|
Update of /cvsroot/compbench/CompBenchmarks++/System In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29432 Modified Files: System.cpp System.h Log Message: New function to get dynamicaly the list of benchmarks / packages according to present libraries. Index: System.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/System/System.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** System.cpp 28 Dec 2006 13:14:30 -0000 1.13 --- System.cpp 28 Dec 2006 18:14:15 -0000 1.14 *************** *** 13,16 **** --- 13,17 ---- #include <unistd.h> #include <ctype.h> + #include <dirent.h> #include <config.h> *************** *** 33,38 **** cbmlib_paths.push_back(tmp); ! cbmlib_paths.push_back("./Benchmark/.libs"); ! cbmlib_paths.push_back("../../Benchmark/.libs"); } --- 34,39 ---- cbmlib_paths.push_back(tmp); ! cbmlib_paths.push_back("./SupportedBenchmarks/.libs"); ! cbmlib_paths.push_back("../../SupportedBenchmarks/.libs"); } *************** *** 115,118 **** --- 116,172 ---- + std::vector<std::string> CBMSystem::bmList(void) + { + DIR *fd; + struct dirent *de; + std::vector<std::string> result; + std::string dum; + unsigned int e; + int p_i; + int p_n = cbmlib_paths.size(); + std::string dir; + + int r_i; + int r_n; + int inserted; + + for(p_i=0;p_i<p_n;p_i++) { + dir=cbmlib_paths[p_i]; + + fd=opendir(dir.c_str()); + if (fd) { + while ( (de=readdir(fd)) != 0) { + dum=de->d_name; + if (dum.size()<=3) + continue; + + if (dum.substr(dum.size()-3) != ".so") + continue; + + if (dum.substr(0, 21) != "libcompbenchmarks-bm-") + continue; + + e=dum.find(".so", 0); + dum=dum.substr(21, e-21); + + inserted=0; + + r_n=result.size(); + for(r_i=0;r_i<r_n;r_i++) { + if (result[r_i] == dum) { + inserted=1; + break; + } + } + + if (!inserted) + result.push_back(dum); + } + } + closedir(fd); + } + + return(result); + } std::string CBMSystem::Split(const std::string& str, const std::string& delim, unsigned int wantedIndex) Index: System.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/System/System.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** System.h 27 Dec 2006 18:22:30 -0000 1.13 --- System.h 28 Dec 2006 18:14:15 -0000 1.14 *************** *** 10,13 **** --- 10,15 ---- #define H_CBMSYSTEM + #include <vector> + #include <string> #include <time.h> *************** *** 112,115 **** --- 114,122 ---- virtual int init(void); + /** Give a list containing the compatible benchmarks + * in declared directories. + * \return a std::string list of benchmarks (id) */ + virtual std::vector<std::string> bmList(void); + /** Split a std::string. * Split given string as sub-strings, according to an arbitrary delimiter. |