MCPcopy Create free account
hub / github.com/clMathLibraries/clSPARSE / findMatrices

Function findMatrices

src/benchmarks/cusparse-bench/src/main.cpp:60–98  ·  view source on GitHub ↗

* @brief findMatrices * @param root path to the directory where to search for files with extension * @param extension matrix files extension without "." just mtx * @param matrix_files vector of found files with given extension * @return true if any files were found */

Source from the content-addressed store, hash-verified

58* @return true if any files were found
59*/
60bool findMatrices( const std::string& root,
61 const std::string& extension,
62 std::vector<fs::path>& matrix_files )
63{
64 fs::path dir( root );
65
66 recursive_directory_range recursive_directory_it(dir);
67
68 const boost::regex filter( ".*\\.\\" + extension );
69 bool found = false;
70
71 if( fs::exists( dir ) && fs::is_directory( dir ) )
72 {
73 for (auto it : recursive_directory_range(dir))
74 {
75 //std::cout << "Checking:" << it << std::endl;
76 if( fs::is_regular_file( it.status( ) ) )
77 {
78 std::string fname = it.path( ).filename( ).string( );
79
80 std::string fname_suffix = fname.substr(fname.size() - 6);
81
82 if( boost::regex_match( fname, filter ) )
83 {
84 std::cout << "\tAdding:" << it.path( ) << std::endl;
85 matrix_files.push_back( it.path( ) );
86 found = true;
87 }
88 }
89 }
90 }
91 else
92 {
93 std::cerr << dir << " does not name a directory or directory does not exists!" << std::endl;
94 return false;
95 }
96
97 return found;
98}
99
100std::vector< fs::path > enumMatrices( const std::string& root_dir )
101{

Callers 1

enumMatricesFunction · 0.70

Calls 2

sizeMethod · 0.45

Tested by

no test coverage detected