MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / VerifyMdfFile

Method VerifyMdfFile

lib/mdflib/mdflib/src/mdfreader.cpp:274–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274void MdfReader::VerifyMdfFile() {
275 if (!file_) {
276 MDF_ERROR() << "No stream attached. Invalid use of function";
277 return;
278 }
279
280 const bool open = Open();
281 if (!open) {
282 MDF_ERROR()
283 << "The file couldn't be opened for reading (locked?). Filename: "
284 << filename_;
285 // No meaning to continue if the file cannot be opened
286 return;
287 }
288
289 auto id_block = std::make_unique<detail::IdBlock>();
290 id_block->Read(*file_);
291
292 if (Platform::strnicmp(id_block->FileId().c_str(), "MDF", 3) == 0 ||
293 Platform::strnicmp(id_block->FileId().c_str(), "UnFinMF", 7) == 0) {
294 if (id_block->Version() >= 400) {
295 instance_ = std::make_unique<detail::Mdf4File>(std::move(id_block));
296 instance_->FileName(filename_);
297 } else {
298 instance_ = std::make_unique<detail::Mdf3File>(std::move(id_block));
299 instance_->FileName(filename_);
300 }
301 if (!instance_) {
302 Close();
303 MDF_ERROR() << "MDF version not supported. File: " << filename_;
304 }
305 } else {
306 MDF_ERROR() << "This is not and MDF file. File: " << filename_;
307 Close();
308 }
309}
310
311MdfReader::~MdfReader() { Close(); }
312

Callers

nothing calls this directly

Calls 5

strnicmpFunction · 0.85
FileIdMethod · 0.80
ReadMethod · 0.45
VersionMethod · 0.45
FileNameMethod · 0.45

Tested by

no test coverage detected