BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
RawFileTools Namespace Reference

Functions

std::vector< std::string > wildcard_correct (const std::string &fname)
 
std::vector< std::string > wildcard_correct (const std::vector< std::string > &fnames)
 
std::string fname2idxname (const std::string &fname)
 
std::string itoa (int i)
 

Function Documentation

◆ fname2idxname()

std::string RawFileTools::fname2idxname ( const std::string &  fname)

Definition at line 69 of file RawFileTools.cxx.

70{
71 std::string::size_type pathend = fname.rfind('/', fname.length());
72 std::string idxname = (pathend != std::string::npos ) ? fname.substr(pathend+1) : fname;
73
74 idxname += ".idx";
75
76 return idxname;
77}

Referenced by main().

◆ itoa()

std::string RawFileTools::itoa ( int  i)

Definition at line 79 of file RawFileTools.cxx.

80{
81 std::stringstream sstr;
82 sstr << i;
83
84 std::string str;
85 sstr >> str;
86
87 while ( str.length() < 3 ) {
88 str = std::string("0") + str;
89 }
90
91 return str;
92}

◆ wildcard_correct() [1/2]

std::vector< std::string > RawFileTools::wildcard_correct ( const std::string &  fname)

Definition at line 5 of file RawFileTools.cxx.

6{
7 static char pbuf[8192];
8 static const std::string lsCom("/bin/ls ");
9
10 std::vector<std::string> newfnames;
11
12 if ( ( fname.find('*', 0) != std::string::npos ) ||
13 ( fname.find('?', 0) != std::string::npos ) )
14 {
15 FILE* ftmp = popen((lsCom+fname).c_str(), "r");
16
17 std::stringstream fnstream;
18 while ( fgets(pbuf, 8192, ftmp) != NULL ) {
19 fnstream << pbuf;
20 }
21
22 std::string tfn;
23 while ( ! (fnstream>>tfn).eof() ) {
24 newfnames.push_back(tfn);
25 }
26 }
27 else {
28 newfnames.push_back(fname);
29 }
30
31 return newfnames;
32}

Referenced by RawFileReader::getEventNumber(), main(), and RawFileReader::RawFileReader().

◆ wildcard_correct() [2/2]

std::vector< std::string > RawFileTools::wildcard_correct ( const std::vector< std::string > &  fnames)

Definition at line 34 of file RawFileTools.cxx.

35{
36 static char pbuf[8192];
37 static const std::string lsCom("/bin/ls ");
38
39 std::vector<std::string> newfnames;
40 std::string fname;
41 std::stringstream fnstream;
42 std::vector<std::string>::const_iterator it = fnames.begin();
43
44 while ( it != fnames.end() ) {
45 if ( ( it->find('*', 0) != std::string::npos ) ||
46 ( it->find('?', 0) != std::string::npos ) ) {
47 // list and get the wildcard files
48 std::string com = lsCom + (*it);
49 FILE* ftmp = popen(com.c_str(), "r");
50
51 fnstream.clear();
52 while ( fgets(pbuf, 8192, ftmp) != NULL ) {
53 fnstream << pbuf;
54 }
55
56 while ( ! (fnstream>>fname).eof() ) {
57 newfnames.push_back(fname);
58 }
59 }
60 else {
61 newfnames.push_back(*it);
62 }
63 ++it;
64 }
65
66 return newfnames;
67}