| 447 | } |
| 448 | |
| 449 | bool 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 | |
| 478 | bool MdfReader::ExportAttachmentData(const IAttachment &attachment, |
| 479 | std::streambuf &dest_buffer) { |
no test coverage detected