BOSS 8.0.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 59 of file RawFileTools.cxx.

59 {
60 std::string::size_type pathend = fname.rfind( '/', fname.length() );
61 std::string idxname = ( pathend != std::string::npos ) ? fname.substr( pathend + 1 ) : fname;
62
63 idxname += ".idx";
64
65 return idxname;
66}

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

◆ itoa()

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

Definition at line 68 of file RawFileTools.cxx.

68 {
69 std::stringstream sstr;
70 sstr << i;
71
72 std::string str;
73 sstr >> str;
74
75 while ( str.length() < 3 ) { str = std::string( "0" ) + str; }
76
77 return str;
78}

◆ wildcard_correct() [1/2]

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

Definition at line 6 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 ) { fnstream << pbuf; }
19
20 std::string tfn;
21 while ( !( fnstream >> tfn ).eof() ) { newfnames.push_back( tfn ); }
22 }
23 else { newfnames.push_back( fname ); }
24
25 return newfnames;
26}

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

◆ wildcard_correct() [2/2]

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

Definition at line 29 of file RawFileTools.cxx.

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