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

Method ExportAttachmentData

lib/mdflib/mdflib/src/mdfreader.cpp:449–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449bool MdfReader::ExportAttachmentData(const IAttachment &attachment,
450 const std::string &dest_file) {
451 if (!instance_ || !file_) {
452 MDF_ERROR() << "No instance created. File: " << filename_;
453 return false;
454 }
455
456 bool shall_close = !IsOpen() && Open();
457 if (!IsOpen()) {
458 MDF_ERROR() << "Failed to open file. File: " << filename_;
459 return false;
460 }
461
462 bool no_error = true;
463 try {
464 auto &at4 = dynamic_cast<const detail::At4Block &>(attachment);
465 at4.ReadData(*file_, dest_file);
466 } catch (const std::exception &error) {
467 MDF_ERROR() << "Failed to read the file information blocks. Error: "
468 << error.what();
469 no_error = false;
470 }
471
472 if (shall_close) {
473 Close();
474 }
475 return no_error;
476}
477
478bool MdfReader::ExportAttachmentData(const IAttachment &attachment,
479 std::streambuf &dest_buffer) {

Callers 1

OnSaveAttachmentMethod · 0.80

Calls 1

ReadDataMethod · 0.45

Tested by

no test coverage detected