BOSS 7.1.0
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 70 of file RawFileTools.cxx.

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

Referenced by GenRdmTrgIdxAlg::execute(), GenRdmTrgIdxAlg::finalize(), and main().

◆ itoa()

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

Definition at line 80 of file RawFileTools.cxx.

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

◆ wildcard_correct() [1/2]

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

Definition at line 6 of file RawFileTools.cxx.

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

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 35 of file RawFileTools.cxx.

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