| 67 | } |
| 68 | |
| 69 | void CreateFileList::ConvertMdfFile(const std::string& file) { |
| 70 | const auto& arguments = ProgramArgument::Instance(); |
| 71 | std::string filename; |
| 72 | std::string stem; |
| 73 | |
| 74 | try { |
| 75 | path fullname(file); |
| 76 | filename = fullname.filename().string(); |
| 77 | stem = fullname.stem().string(); |
| 78 | if (output_path_.empty()) { |
| 79 | output_path_ = fullname.parent_path().string(); |
| 80 | } |
| 81 | } catch (const std::exception& err) { |
| 82 | MDF_ERROR() << "Invalid file path. Error :" << err.what(); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | MdfReader reader(file); |
| 87 | if (!reader.IsOk()) { |
| 88 | MDF_INFO() << filename << ". Skipping. Invalid MDF file."; |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | const bool read = reader.ReadEverythingButData(); |
| 93 | if (!read) { |
| 94 | MDF_INFO() << filename << ". Skipping. Read failure."; |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | const IHeader* header = reader.GetHeader(); |
| 99 | if (header == nullptr) { |
| 100 | MDF_INFO() << ". Skipping. No file header."; |
| 101 | return; |
| 102 | } |
| 103 | const auto dg_list = header->DataGroups(); |
| 104 | if (dg_list.empty()) { |
| 105 | // Nothing to convert |
| 106 | MDF_INFO() << ". Skipping. No data groups."; |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | size_t measure_no = 0; // Used to set a unique CSV name. |
| 111 | for (auto* dg_group : dg_list) { |
| 112 | if (dg_group == nullptr) { |
| 113 | continue; |
| 114 | } |
| 115 | ++measure_no; |
| 116 | size_t group_no = 0; // Used if the CG doesn't have a name. |
| 117 | std::vector<IChannelGroup*> cg_list; |
| 118 | const auto temp_list = dg_group->ChannelGroups(); |
| 119 | for (auto* temp_group : temp_list) { |
| 120 | if (temp_group == nullptr) { |
| 121 | continue; |
| 122 | } |
| 123 | if ((temp_group->Flags() & CgFlag::VlsdChannel) != 0) { |
| 124 | continue; |
| 125 | } |
| 126 | if (temp_group->NofSamples() == 0) { |