2 #include <boost/numeric/conversion/bounds.hpp>
3 #include <boost/filesystem.hpp>
4 #include <boost/foreach.hpp>
5 #include <boost/lexical_cast.hpp>
22 namespace bf = boost::filesystem;
23 using boost::lexical_cast;
24 using boost::bad_lexical_cast;
31 declareProperty(
"EventsPerFile", m_eventsPerFile
32 = boost::numeric::bounds< unsigned int>::highest() );
33 declareProperty(
"NumericFilename", m_numericFilename =
false );
34 declareProperty(
"NumbersAdded", m_nNumbersAdded = 6 );
71 string filename = outputPath.filename().string();
72 bf::path dir = outputPath.parent_path();
73 string stem = outputPath.stem().string();
74 string extension = outputPath.extension().string();
77 if ( !bf::exists( dir ) ) {
79 stream <<
"Directory " << dir <<
" does not exist.";
87 m_iFile = lexical_cast<
unsigned int >( stem );
88 }
catch(
const bad_lexical_cast& ) {
90 stream <<
"Filename " << filename
91 <<
" is not a number, which was needed.";
97 string iFile( iFileStream.str() );
98 unsigned int length = 0;
100 if ( stem.length() > iFile.length() ) {
101 length = stem.length() - iFile.length();
105 if ( !dir.empty() ) {
108 for (
unsigned int i = 0;
i < length; ++
i ) {
111 name << iFile << extension;
115 size_t pos = stem.rfind(
"_" );
116 stem = stem.substr( 0, pos );
121 string iFile( iFileStream.str() );
123 unsigned int length = 0;
129 name << dir <<
"/" << stem;
130 for (
unsigned int i = 0;
i < length; ++
i ) {
131 if (
i == 0 ) name <<
"_";
134 name << iFile << extension;