All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WildcardSource.cxx
Go to the documentation of this file.
2 
4 
5 #include "ifdh.h"
6 
7 #include <algorithm>
8 
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <unistd.h>
12 #include <iostream>
13 namespace
14 {
15  // No-one else needs to see this
16  std::vector<std::string> sorted(const std::vector<std::string>& v)
17  {
18  std::vector<std::string> ret;
19  ret = v;
20  std::sort(ret.begin(), ret.end());
21  return ret;
22  }
23 }
24 
25 namespace ana
26 {
27  //----------------------------------------------------------------------
28  WildcardSource::WildcardSource(const std::string& wildcard,
29  int stride, int offset)
30  // MRCCLoader needs all its lists in matching order, so sort here
31  : FileListSource(sorted(WildcardOrLs(wildcard)), stride, offset)
32  {
33  }
34 
35  //----------------------------------------------------------------------
37  {
38  }
39 
40  //----------------------------------------------------------------------
41  std::vector<std::string> WildcardSource::
42  WildcardOrLs(const std::string& wildcard) const
43  {
44  std::vector<std::string> ret = Wildcard(wildcard);
45 
46  struct stat ss;
47  // If we found nothing, but it's because pnfs isn't mounted, try ifdh ls
48  // instead.
49  if(ret.empty() &&
50  wildcard.find("/pnfs/") == 0 &&
51  stat("/pnfs/", &ss) != 0){
52 
53  std::cout << "No files matching " << wildcard << " but that's probably because /pnfs is not mounted on the current node." << std::endl;
54 
55  // This doesn't work because "ifdh ls" doesn't actually understand
56  // wildcard syntax properly.
57  // ifdh i;
58  // ret = i.ls(wildcard, 0);
59  }
60 
61  return ret;
62  }
63 }
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
Definition: CORSIKAGen.fcl:7
std::vector< std::string > Wildcard(const std::string &wildcardString)
process_name opflashCryoW ana
WildcardSource(const std::string &wildcard, int stride=-1, int offset=-1)
std::vector< std::string > WildcardOrLs(const std::string &wildcard) const
Simple file source based on an explicit list provided by the user.
BEGIN_PROLOG could also be cout