90{
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
111
113
114 if (infofile.isEmpty())
115 return "Given empty path to info file";
116 QFileInfo fi(infofile);
117 if (!fi.exists())
118 return "infofile "+infofile+" does not exist";
119 if (!fi.isReadable())
120 return "infofile "+infofile+" is not readable";
121 if (fi.size()==0)
122 return "infofile "+infofile+" is not empty";
123
125
127
128 int i_begin_copyresult(-1), i_end_copyresult(-1);
129 int i_begin_checksums(-1), i_end_checksums(-1);
130
131
133 QFile
file(infofile);
134 if (!
file.open(QFile::ReadOnly))
135 return "Could not open file in readonly mode";
136
137
138
139 const qint64 max_linelength(1000);
140 const qint64 max_numberoflines(2000);
141 qint64 ilines(0);
142
145
146 if (ilines++>max_numberoflines)
147 return "Too many lines in file";
148
149
150 QString rawline =
stream.readLine(max_linelength).simplified();
151 if (rawline.isEmpty())
152 continue;
153
154
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();
171 }
172
173
175 }
177 return "Did not read any lines from file";
178
179
180 const bool hascopyresult(i_begin_copyresult!=-1||i_end_copyresult!=-1);
181
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";
185
186 if (hascopyresult) {
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";
194 }
195
197
199
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 );
203#else
204 QStringList
parts =
lines.at(i).split (
' ', QString::SkipEmptyParts );
205#endif
206 if (
parts.count()!=2)
207 return "Invalid line in checksums section";
211 return "Invalid md5sum in checksums section: "+md5sum;
212 VP1EventFile
evt(filename,md5sum);
214 return "Failed to decode event file information from filename: "+
filename;
216 }
217
219
220 if (hascopyresult) {
221
222
223 }
224
225 return "";
226}
QList< VP1EventFile > events
static bool validMD5Sum(const QString &)
static QString sumToStandardFormat(const QString &)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.