18 #include <QTextStream>
19 #include <QtCoreVersion>
26 Imp(
const QString& infofile)
32 QString
init(
const QString& infofile);
69 l <<
"Invalid. Reason: " +
error();
75 l <<
"Events within 10 minutes of latest:";
78 l <<
"Events with same run number as latest:";
81 l <<
"Events with same run number as latest and within 1 minute:";
114 if (infofile.isEmpty())
115 return "Given empty path to info file";
116 QFileInfo
fi(infofile);
118 return "infofile "+infofile+
" does not exist";
119 if (!
fi.isReadable())
120 return "infofile "+infofile+
" is not readable";
122 return "infofile "+infofile+
" is not empty";
128 int i_begin_copyresult(-1), i_end_copyresult(-1);
129 int i_begin_checksums(-1), i_end_checksums(-1);
133 QFile
file(infofile);
134 if (!
file.open(QFile::ReadOnly))
135 return "Could not open file in readonly mode";
139 const qint64 max_linelength(1000);
140 const qint64 max_numberoflines(2000);
146 if (ilines++>max_numberoflines)
147 return "Too many lines in file";
150 QString rawline =
stream.readLine(max_linelength).simplified();
151 if (rawline.isEmpty())
155 if (rawline==
"begin_copyresult") {
156 if (i_begin_copyresult!=-1)
157 return "Saw two lines with begin_copyresult";
158 i_begin_copyresult =
lines.count();
159 }
else if (rawline==
"end_copyresult") {
160 if (i_end_copyresult!=-1)
161 return "Saw two lines with end_copyresult";
162 i_end_copyresult =
lines.count();
163 }
else if (rawline==
"begin_checksums") {
164 if (i_begin_checksums!=-1)
165 return "Saw two lines with begin_checksums";
166 i_begin_checksums =
lines.count();
167 }
else if (rawline==
"end_checksums") {
168 if (i_end_checksums!=-1)
169 return "Saw two lines with end_checksums";
170 i_end_checksums =
lines.count();
177 return "Did not read any lines from file";
180 const bool hascopyresult(i_begin_copyresult!=-1||i_end_copyresult!=-1);
182 if (i_begin_checksums==-1)
return "File did not have begin_checksums line";
183 if (i_end_checksums==-1)
return "File did not have end_checksums line";
184 if (i_end_checksums<=i_begin_checksums)
return "checksum section delimiters out of order";
187 if (i_begin_copyresult==-1)
return "File had end_copyresult but no begin_copyresult line";
188 if (i_end_copyresult==-1)
return "File had begin_copyresult but no end_copyresult line";
189 if (i_end_copyresult<=i_begin_copyresult)
return "copyresult section delimiters out of order";
190 if (i_begin_copyresult>i_begin_checksums&&i_begin_copyresult<i_end_checksums)
191 return "copyresult and checksum sections mixed";
192 if (i_end_copyresult>i_begin_checksums&&i_end_copyresult<i_end_checksums)
193 return "copyresult and checksum sections mixed";
200 for (
int i = i_begin_checksums+1;
i < i_end_checksums; ++
i) {
201 #if QTCORE_VERSION >= 0x050E00
202 QStringList
parts =
lines.at(
i).split (
' ', Qt::SkipEmptyParts );
204 QStringList
parts =
lines.at(
i).split (
' ', QString::SkipEmptyParts );
206 if (
parts.count()!=2)
207 return "Invalid line in checksums section";
211 return "Invalid md5sum in checksums section: "+md5sum;
214 return "Failed to decode event file information from filename: "+
filename;
249 QList<VP1EventFile>
l;
253 const unsigned newestRawTime =
m_d->
events.at(0).rawTime();
254 const int newestRunNumber =
m_d->
events.at(0).runNumber();
256 const unsigned minTime = (timecut<0&&
unsigned(timecut)>newestRawTime) ? 0 : newestRawTime-timecut;
258 QList<VP1EventFile>
out;
260 if (minTime>0&&
evt.rawTime()<minTime)
262 if (requireNewestRunNumber&&
evt.runNumber()!=newestRunNumber)