search_path_test_2.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // test search_path
4 //
5 // ======================================================================
6 
7 #include "cetlib/search_path.h"
8 
9 #include <algorithm>
10 #include <iostream>
11 #include <iterator>
12 #include <string>
13 #include <vector>
14 
15 using cet::search_path;
16 
17 typedef std::vector<std::string> strings_t;
18 
19 /*
20  example regular expression = "^lib([A-Za-z0-9_]+)_plugin.so$"
21 
22  This program needs to be driven by a shell script to make
23  management of files easier, such as creating and destroying
24  temporary directories and files.
25 */
26 
27 int
28 main(int argc, char* argv[])
29 {
30  if (argc < 3) {
31  std::cerr << "usage: " << argv[0] << " regex_pattern directory_name\n";
32  return -1;
33  }
34 
35  strings_t results;
36  std::size_t count =
37  search_path(argv[2]).find_files(argv[1], std::back_inserter(results));
38 
39  std::copy(results.begin(),
40  results.end(),
41  std::ostream_iterator<std::string>(std::cout, "\n"));
42 
43  return count;
44 }
std::vector< std::string > strings_t
std::size_t find_files(std::string const &filename_pattern, std::vector< std::string > &result) const
Definition: search_path.cc:126
int main(int argc, char *argv[])
T copy(T const &v)